public inbox for linux-usb@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] usb: gadget: udc: fix possible null-ptr-deref in mv_u3d_req_to_trb()
@ 2024-10-26 10:27 Yi Yang
  2024-10-29  3:36 ` Greg KH
  0 siblings, 1 reply; 2+ messages in thread
From: Yi Yang @ 2024-10-26 10:27 UTC (permalink / raw)
  To: gregkh, kees, justinstitt, u.kleine-koenig, yuxu, balbi
  Cc: linux-usb, wangweiyang2

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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-10-29  3:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-26 10:27 [PATCH] usb: gadget: udc: fix possible null-ptr-deref in mv_u3d_req_to_trb() Yi Yang
2024-10-29  3:36 ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox