All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
To: cgel.zte@gmail.com, balbi@kernel.org
Cc: gregkh@linuxfoundation.org, peter.chen@kernel.org,
	skhan@linuxfoundation.org, lv.ruyi@zte.com.cn, johan@kernel.org,
	jakobkoschel@gmail.com, linux-usb@vger.kernel.org,
	linux-kernel@vger.kernel.org, Zeal Robot <zealci@zte.com.cn>
Subject: Re: [PATCH] usb: gadget: udc: add NULL pointer check
Date: Tue, 29 Mar 2022 20:47:38 +0200	[thread overview]
Message-ID: <63e05f0a-6fb0-c7dc-0c3a-467a5c4e11da@wanadoo.fr> (raw)
In-Reply-To: <20220329055407.2375626-1-lv.ruyi@zte.com.cn>


Le 29/03/2022 à 07:54, cgel.zte@gmail.com a écrit :
> From: Lv Ruyi <lv.ruyi@zte.com.cn>
>
> kzalloc() is a memory allocation function which can return NULL when some
> internal memory errors happen. It is safer to check NULL pointer.
>
> Reported-by: Zeal Robot <zealci@zte.com.cn>
> Signed-off-by: Lv Ruyi <lv.ruyi@zte.com.cn>
> ---
>   drivers/usb/gadget/udc/mv_udc_core.c | 4 ++++
>   1 file changed, 4 insertions(+)
>
> diff --git a/drivers/usb/gadget/udc/mv_udc_core.c b/drivers/usb/gadget/udc/mv_udc_core.c
> index fdb17d86cd65..f52eb3f2420a 100644
> --- a/drivers/usb/gadget/udc/mv_udc_core.c
> +++ b/drivers/usb/gadget/udc/mv_udc_core.c
> @@ -2231,6 +2231,10 @@ static int mv_udc_probe(struct platform_device *pdev)
>   
>   	/* allocate a small amount of memory to get valid address */
>   	udc->status_req->req.buf = kzalloc(8, GFP_KERNEL);
> +	if (!udc->status_req->req.buf) {
> +		retval = -ENOMEM;
> +		goto err_destroy_dma;
> +	}

Hi,

not directly related to this patch, but I wonder if this kzalloc should 
be freed in the error handling path, and maybe also in the .remove 
function. It seems to be leaking.

CJ

>   	udc->status_req->req.dma = DMA_ADDR_INVALID;
>   
>   	udc->resume_state = USB_STATE_NOTATTACHED;

      parent reply	other threads:[~2022-03-29 18:47 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-29  5:54 [PATCH] usb: gadget: udc: add NULL pointer check cgel.zte
2022-03-29 14:32 ` Shuah Khan
2022-03-29 18:47 ` Christophe JAILLET [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=63e05f0a-6fb0-c7dc-0c3a-467a5c4e11da@wanadoo.fr \
    --to=christophe.jaillet@wanadoo.fr \
    --cc=balbi@kernel.org \
    --cc=cgel.zte@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jakobkoschel@gmail.com \
    --cc=johan@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=lv.ruyi@zte.com.cn \
    --cc=peter.chen@kernel.org \
    --cc=skhan@linuxfoundation.org \
    --cc=zealci@zte.com.cn \
    /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.