OSDN Git Service

dm: fix casting bug in dm_merge_bvec()
authorJoe Thornber <ejt@redhat.com>
Fri, 29 May 2015 13:52:51 +0000 (14:52 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 6 Jun 2015 15:21:08 +0000 (08:21 -0700)
commitee609242fe218d874b8d0779e82fcde7af4aa09b
treec1e5050ef1a196d9b003d64a5e9ffc67cc1ebcda
parentefbf9472653b6e4546ac7f38fee6cf3387c56926
dm: fix casting bug in dm_merge_bvec()

commit 1c220c69ce0dcc0f234a9f263ad9c0864f971852 upstream.

dm_merge_bvec() was originally added in f6fccb ("dm: introduce
merge_bvec_fn").  In that commit a value in sectors is converted to
bytes using << 9, and then assigned to an int.  This code made
assumptions about the value of BIO_MAX_SECTORS.

A later commit 148e51 ("dm: improve documentation and code clarity in
dm_merge_bvec") was meant to have no functional change but it removed
the use of BIO_MAX_SECTORS in favor of using queue_max_sectors().  At
this point the cast from sector_t to int resulted in a zero value.  The
fallout being dm_merge_bvec() would only allow a single page to be added
to a bio.

This interim fix is minimal for the benefit of stable@ because the more
comprehensive cleanup of passing a sector_t to all DM targets' merge
function will impact quite a few DM targets.

Signed-off-by: Joe Thornber <ejt@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/md/dm.c