From: cgel.zte@gmail.com
To: balbi@kernel.org
Cc: gregkh@linuxfoundation.org, peter.chen@kernel.or,
christophe.jaillet@wanadoo.fr, 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: [PATCH] usb: gadget: udc: add NULL pointer check
Date: Tue, 29 Mar 2022 05:54:07 +0000 [thread overview]
Message-ID: <20220329055407.2375626-1-lv.ruyi@zte.com.cn> (raw)
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;
+ }
udc->status_req->req.dma = DMA_ADDR_INVALID;
udc->resume_state = USB_STATE_NOTATTACHED;
--
2.25.1
next reply other threads:[~2022-03-29 5:54 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-29 5:54 cgel.zte [this message]
2022-03-29 14:32 ` Shuah Khan
2022-03-29 18:47 ` Christophe JAILLET
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=20220329055407.2375626-1-lv.ruyi@zte.com.cn \
--to=cgel.zte@gmail.com \
--cc=balbi@kernel.org \
--cc=christophe.jaillet@wanadoo.fr \
--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.or \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®