From: Greg Kroah-Hartman Date: Tue, 26 Feb 2013 18:06:27 +0000 (-0800) Subject: 3.4-stable patches X-Git-Tag: v3.7.10~23 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=674711fc094f73bb8d7b9f5806cbf474ca81fd6f;p=thirdparty%2Fkernel%2Fstable-queue.git 3.4-stable patches added patches: target-fix-divide-by-zero-bug-in-fabric_max_sectors-for-unconfigured-devices.patch --- diff --git a/queue-3.4/series b/queue-3.4/series index 1a156b0368c..913aa6c531f 100644 --- a/queue-3.4/series +++ b/queue-3.4/series @@ -48,3 +48,4 @@ drm-don-t-add-inferred-modes-for-monitors-that-don-t-support-them.patch drm-fill-depth-bits_per_pixel-for-c8-format.patch drm-use-c8-instead-of-rgb332-when-determining-the-format-from-depth-bpp.patch drm-usb-bind-driver-to-correct-device.patch +target-fix-divide-by-zero-bug-in-fabric_max_sectors-for-unconfigured-devices.patch diff --git a/queue-3.4/target-fix-divide-by-zero-bug-in-fabric_max_sectors-for-unconfigured-devices.patch b/queue-3.4/target-fix-divide-by-zero-bug-in-fabric_max_sectors-for-unconfigured-devices.patch new file mode 100644 index 00000000000..2dd8cca2728 --- /dev/null +++ b/queue-3.4/target-fix-divide-by-zero-bug-in-fabric_max_sectors-for-unconfigured-devices.patch @@ -0,0 +1,54 @@ +From nab@linux-iscsi.org Tue Feb 26 10:03:15 2013 +From: "Nicholas A. Bellinger" +Date: Tue, 19 Feb 2013 03:15:14 +0000 +Subject: target: Fix divide by zero bug in fabric_max_sectors for unconfigured devices +To: target-devel +Cc: Nicholas Bellinger , Herton Ronaldo Krzesinski , Greg Kroah-Hartman +Message-ID: <1361243714-4765-1-git-send-email-nab@linux-iscsi.org> + + +From: Nicholas Bellinger + +commit 7a3cf6ca1ab2a2f7161c6dec5a787fc7a5de864e upstream + +This patch fixes a possible divide by zero bug when the fabric_max_sectors +device attribute is written and backend se_device failed to be successfully +configured -> enabled. + +Go ahead and use block_size=512 within se_dev_set_fabric_max_sectors() +in the event of a target_configure_device() failure case, as no valid +dev->dev_attrib.block_size value will have been setup yet. + +Signed-off-by: Nicholas Bellinger +Cc: Herton Ronaldo Krzesinski +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/target/target_core_device.c | 8 +++++++- + 1 file changed, 7 insertions(+), 1 deletion(-) + +--- a/drivers/target/target_core_device.c ++++ b/drivers/target/target_core_device.c +@@ -1230,6 +1230,8 @@ int se_dev_set_max_sectors(struct se_dev + + int se_dev_set_fabric_max_sectors(struct se_device *dev, u32 fabric_max_sectors) + { ++ int block_size = dev->se_sub_dev->se_dev_attrib.block_size; ++ + if (atomic_read(&dev->dev_export_obj.obj_access_count)) { + pr_err("dev[%p]: Unable to change SE Device" + " fabric_max_sectors while dev_export_obj: %d count exists\n", +@@ -1267,8 +1269,12 @@ int se_dev_set_fabric_max_sectors(struct + /* + * Align max_sectors down to PAGE_SIZE to follow transport_allocate_data_tasks() + */ ++ if (!block_size) { ++ block_size = 512; ++ pr_warn("Defaulting to 512 for zero block_size\n"); ++ } + fabric_max_sectors = se_dev_align_max_sectors(fabric_max_sectors, +- dev->se_sub_dev->se_dev_attrib.block_size); ++ block_size); + + dev->se_sub_dev->se_dev_attrib.fabric_max_sectors = fabric_max_sectors; + pr_debug("dev[%p]: SE Device max_sectors changed to %u\n",