RE: [PATCH] fix kzalloc in scsi device handler

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Agree.. But this may not fix the problem completely.. Please see my comments below.. 
Also copied Chandra if he has any comments.. 

> -----Original Message-----
> From: linux-scsi-owner@xxxxxxxxxxxxxxx [mailto:linux-scsi-
> owner@xxxxxxxxxxxxxxx] On Behalf Of Hillf Danton
> Sent: Tuesday, November 16, 2010 7:34 AM
> To: linux-scsi@xxxxxxxxxxxxxxx
> Subject: [PATCH] fix kzalloc in scsi device handler
> 
> They look like typo, since there are four instances of kzalloc almost
> typed by the same finger.
> 
> The pointer is replaced with a struct, which helps kzalloc return
> correct result.
> 
> thanks for any comment on the possibility that mem overflow could
> happen.
> 
> Signed-off-by: Hillf Danton <dhillf@xxxxxxxxx>
> ---
> 
> --- a/drivers/scsi/device_handler/scsi_dh_alua.c	2010-11-01
> 19:54:12.000000000 +0800
> +++ b/drivers/scsi/device_handler/scsi_dh_alua.c	2010-11-16
> 20:40:36.000000000 +0800
> @@ -759,7 +759,7 @@ static int alua_bus_attach(struct scsi_d
>  	unsigned long flags;
>  	int err = SCSI_DH_OK;
> 
> -	scsi_dh_data = kzalloc(sizeof(struct scsi_device_handler *)
> +	scsi_dh_data = kzalloc(sizeof(struct scsi_dh_data)
>  			       + sizeof(*h) , GFP_KERNEL);

I think this should be like this below. 

      scsi_dh_data = kzalloc(sizeof(struct scsi_dh_data)
  			       + sizeof(struct alua_dh_data) , GFP_KERNEL);

Same thing should apply for all the below segments..

>  	if (!scsi_dh_data) {
>  		sdev_printk(KERN_ERR, sdev, "%s: Attach failed\n",
> --- a/drivers/scsi/device_handler/scsi_dh_emc.c	2010-11-01
> 19:54:12.000000000 +0800
> +++ b/drivers/scsi/device_handler/scsi_dh_emc.c	2010-11-16
> 20:40:38.000000000 +0800
> @@ -650,7 +650,7 @@ static int clariion_bus_attach(struct sc
>  	unsigned long flags;
>  	int err;
> 
> -	scsi_dh_data = kzalloc(sizeof(struct scsi_device_handler *)
> +	scsi_dh_data = kzalloc(sizeof(struct scsi_dh_data)
>  			       + sizeof(*h) , GFP_KERNEL);
>  	if (!scsi_dh_data) {
>  		sdev_printk(KERN_ERR, sdev, "%s: Attach failed\n",
> --- a/drivers/scsi/device_handler/scsi_dh_hp_sw.c	2010-11-01
> 19:54:12.000000000 +0800
> +++ b/drivers/scsi/device_handler/scsi_dh_hp_sw.c	2010-11-16
> 20:40:36.000000000 +0800
> @@ -338,7 +338,7 @@ static int hp_sw_bus_attach(struct scsi_
>  	unsigned long flags;
>  	int ret;
> 
> -	scsi_dh_data = kzalloc(sizeof(struct scsi_device_handler *)
> +	scsi_dh_data = kzalloc(sizeof(struct scsi_dh_data)
>  			       + sizeof(struct hp_sw_dh_data) , GFP_KERNEL);
>  	if (!scsi_dh_data) {
>  		sdev_printk(KERN_ERR, sdev, "%s: Attach Failed\n",
> --- a/drivers/scsi/device_handler/scsi_dh_rdac.c	2010-11-01
> 19:54:12.000000000 +0800
> +++ b/drivers/scsi/device_handler/scsi_dh_rdac.c	2010-11-16
> 20:40:32.000000000 +0800
> @@ -800,7 +800,7 @@ static int rdac_bus_attach(struct scsi_d
>  	int err;
>  	char array_name[ARRAY_LABEL_LEN];
> 
> -	scsi_dh_data = kzalloc(sizeof(struct scsi_device_handler *)
> +	scsi_dh_data = kzalloc(sizeof(struct scsi_dh_data)
>  			       + sizeof(*h) , GFP_KERNEL);
>  	if (!scsi_dh_data) {
>  		sdev_printk(KERN_ERR, sdev, "%s: Attach failed\n",
> --
> To unsubscribe from this list: send the line "unsubscribe linux-scsi"
> in
> the body of a message to majordomo@xxxxxxxxxxxxxxx
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
ÿô.nlj·Ÿ®‰­†+%ŠË±é¥Šwÿº{.nlj·¥Š{±þÇ‹ø¡Ü}©ž²ÆzÚj:+v‰¨þø®w¥þŠàÞ¨è&¢)ß«a¶Úÿûz¹ÞúŽŠÝjÿŠwèf



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]
  Powered by Linux