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)
committerNicholas Bellinger <nab@linux-iscsi.org>
Thu, 1 Nov 2012 07:38:44 +0000 (00:38 -0700)
commit3e03989b5868acf69a391a424dc71fcd6cc48167
treec187fcbe2d9861d10e9256725990f266da1f246d
parent0d0f9dfb31e0a6c92063e235417b42df185b3275
target: Avoid integer overflow in se_dev_align_max_sectors()

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>
Cc: stable@vger.kernel.org
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
drivers/target/target_core_device.c