On Tue, Feb 19, 2013 at 03:15:14AM +0000, Nicholas A. Bellinger wrote:
> From: Nicholas Bellinger <[email protected]>
> 
> Hi Greg,
> 
> Please apply this backported bugfix to 3.7.y-stable and 3.4.y-stable.
> 
> Thanks!

Patch was applied to 3.5 tree, thanks.

> 
> --nab
> 
> 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.
> 
> Cc: Herton Ronaldo Krzesinski <[email protected]>
> Cc: Greg Kroah-Hartman <[email protected]>
> Cc: [email protected]
> Signed-off-by: Nicholas Bellinger <[email protected]>
> ---
>  drivers/target/target_core_device.c |    8 +++++++-
>  1 files changed, 7 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/target/target_core_device.c 
> b/drivers/target/target_core_device.c
> index 0943ff0..94fda90 100644
> --- a/drivers/target/target_core_device.c
> +++ b/drivers/target/target_core_device.c
> @@ -1195,6 +1195,8 @@ int se_dev_set_queue_depth(struct se_device *dev, u32 
> queue_depth)
>  
>  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",
> @@ -1232,8 +1234,12 @@ int se_dev_set_fabric_max_sectors(struct se_device 
> *dev, u32 fabric_max_sectors)
>       /*
>        * 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",
> -- 
> 1.7.2.5
> 

-- 
[]'s
Herton
--
To unsubscribe from this list: send the line "unsubscribe stable" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to