All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jack Wang <xjtuwjp@gmail.com>
To: Suresh Thiagarajan <Suresh.Thiagarajan@pmcs.com>
Cc: linux-scsi@vger.kernel.org, JBottomley@parallels.com,
	Vasanthalakshmi.Tharmarajan@pmcs.com, Viswas.G@pmcs.com
Subject: Re: [PATCH] pm80xx : Fix missing NULL pointer checks and memory leaks
Date: Mon, 12 May 2014 10:08:46 +0200	[thread overview]
Message-ID: <5370818E.4070601@gmail.com> (raw)
In-Reply-To: <1399615261-15932-1-git-send-email-Suresh.Thiagarajan@pmcs.com>

On 05/09/2014 08:01 AM, Suresh Thiagarajan wrote:
> Checking return value for the memory allocattion and freeing it
> while exiting the function
> 
> Signed-off-by: Viswas G <Viswas.G@pmcs.com>
> Signed-off-by: Suresh Thiagarajan <Suresh.Thiagarajan@pmcs.com>
> ---
>  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);
> 
Thanks, looks good.
Acked-by: Jack Wang <xjtuwjp@gmail.com>

      parent reply	other threads:[~2014-05-12  8:08 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-09  6:01 [PATCH] pm80xx : Fix missing NULL pointer checks and memory leaks Suresh Thiagarajan
2014-05-10 19:04 ` Tomas Henzl
2014-05-12  8:08 ` Jack Wang [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5370818E.4070601@gmail.com \
    --to=xjtuwjp@gmail.com \
    --cc=JBottomley@parallels.com \
    --cc=Suresh.Thiagarajan@pmcs.com \
    --cc=Vasanthalakshmi.Tharmarajan@pmcs.com \
    --cc=Viswas.G@pmcs.com \
    --cc=linux-scsi@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.