]> git.karo-electronics.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:15:55 +0000 (13:15 -0800)
commit227ab73196544a25f0c03338c5b49d3fdc1d1e38
treeb987a8cbba2a2bdbea7bb2081294fd0206d796d7
parent506485a3c6d926cc01e6d05088eac94adf1d6ae5
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