public inbox for linux-usb@vger.kernel.org
 help / color / mirror / Atom feed
From: Yi Yang <yiyang13@huawei.com>
To: <gregkh@linuxfoundation.org>, <kees@kernel.org>,
	<justinstitt@google.com>, <u.kleine-koenig@baylibre.com>,
	<yuxu@marvell.com>, <balbi@ti.com>
Cc: <linux-usb@vger.kernel.org>, <wangweiyang2@huawei.com>
Subject: [PATCH] usb: gadget: udc: fix possible null-ptr-deref in mv_u3d_req_to_trb()
Date: Sat, 26 Oct 2024 10:27:40 +0000	[thread overview]
Message-ID: <20241026102740.2653458-1-yiyang13@huawei.com> (raw)

The mv_u3d_build_trb_one() will return NULL when kzalloc() fails, fix
possible null-ptr-deref by add check for mv_u3d_build_trb_one().

Fixes: 3d4eb9dfa3e8 ("usb: gadget: mv: Add USB 3.0 device driver for Marvell PXA2128 chip.")
Signed-off-by: Yi Yang <yiyang13@huawei.com>
---
 drivers/usb/gadget/udc/mv_u3d_core.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/usb/gadget/udc/mv_u3d_core.c b/drivers/usb/gadget/udc/mv_u3d_core.c
index 062f43e146aa..c882c377c4f4 100644
--- a/drivers/usb/gadget/udc/mv_u3d_core.c
+++ b/drivers/usb/gadget/udc/mv_u3d_core.c
@@ -417,6 +417,8 @@ static int mv_u3d_req_to_trb(struct mv_u3d_req *req)
 	 */
 	if (length <= (unsigned)MV_U3D_EP_MAX_LENGTH_TRANSFER) {
 		trb = mv_u3d_build_trb_one(req, &count, &dma);
+		if (!trb)
+			return -ENOMEM;
 		list_add_tail(&trb->trb_list, &req->trb_list);
 		req->trb_head = trb;
 		req->trb_count = 1;
-- 
2.25.1


             reply	other threads:[~2024-10-26 10:35 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-26 10:27 Yi Yang [this message]
2024-10-29  3:36 ` [PATCH] usb: gadget: udc: fix possible null-ptr-deref in mv_u3d_req_to_trb() Greg KH

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=20241026102740.2653458-1-yiyang13@huawei.com \
    --to=yiyang13@huawei.com \
    --cc=balbi@ti.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=justinstitt@google.com \
    --cc=kees@kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=u.kleine-koenig@baylibre.com \
    --cc=wangweiyang2@huawei.com \
    --cc=yuxu@marvell.com \
    /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