Re: [PATCH] pm80xx : Fix missing NULL pointer checks and memory leaks

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

 



On 05/09/2014 08:01 AM, Suresh Thiagarajan wrote:
> Checking return value for the memory allocattion and freeing it
> while exiting the function

The fix seems fine to me.
Reviewed-by: Tomas Henzl <thenzl@xxxxxxxxxx>

Tomas

>
> Signed-off-by: Viswas G <Viswas.G@xxxxxxxx>
> Signed-off-by: Suresh Thiagarajan <Suresh.Thiagarajan@xxxxxxxx>
> ---
>  drivers/scsi/pm8001/pm8001_ctl.c |    3 +++
>  1 files changed, 3 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/scsi/pm8001/pm8001_ctl.c b/drivers/scsi/pm8001/pm8001_ctl.c
> index 28b4e81..5f68571 100644
> --- a/drivers/scsi/pm8001/pm8001_ctl.c
> +++ b/drivers/scsi/pm8001/pm8001_ctl.c
> @@ -395,6 +395,8 @@ static ssize_t pm8001_ctl_bios_version_show(struct device *cdev,
>  	payload.offset = 0;
>  	payload.length = 4096;
>  	payload.func_specific = kzalloc(4096, GFP_KERNEL);
> +	if (!payload.func_specific)
> +		return -ENOMEM;
>  	PM8001_CHIP_DISP->get_nvmd_req(pm8001_ha, &payload);
>  	wait_for_completion(&completion);
>  	virt_addr = pm8001_ha->memoryMap.region[NVMD].virt_ptr;
> @@ -402,6 +404,7 @@ static ssize_t pm8001_ctl_bios_version_show(struct device *cdev,
>  		bios_index++)
>  		str += sprintf(str, "%c",
>  			*((u8 *)((u8 *)virt_addr+bios_index)));
> +	kfree(payload.func_specific);
>  	return str - buf;
>  }
>  static DEVICE_ATTR(bios_version, S_IRUGO, pm8001_ctl_bios_version_show, NULL);

--
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




[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