]> git.kernelconcepts.de Git - karo-tx-linux.git/commit
target: Avoid integer overflow in se_dev_align_max_sectors()
authorRoland Dreier <roland@purestorage.com>
Wed, 31 Oct 2012 16:16:45 +0000 (09:16 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 17 Nov 2012 21:18:29 +0000 (13:18 -0800)
commit323ef3123473ecaa03d248082e4107f0cc48b871
tree921cb7f79a174fbb90ed2ca00e7a2f83db39fbd6
parent3a62d0ff8b88d2ee9fe26f466a36d2145e6ac923
target: Avoid integer overflow in se_dev_align_max_sectors()

commit 3e03989b5868acf69a391a424dc71fcd6cc48167 upstream.

The expression (max_sectors * block_size) might overflow a u32
(indeed, since iblock sets max_hw_sectors to UINT_MAX, it is
guaranteed to overflow and end up with a much-too-small result in many
common cases).  Fix this by doing an equivalent calculation that
doesn't require multiplication.

While we're touching this code, avoid splitting a printk format across
two lines and use pr_info(...) instead of printk(KERN_INFO ...).

Signed-off-by: Roland Dreier <roland@purestorage.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/target/target_core_device.c