All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] usb: gadget: ci: Avoid null pointer dereference
@ 2022-01-28  3:39 Marek Vasut
  0 siblings, 0 replies; only message in thread
From: Marek Vasut @ 2022-01-28  3:39 UTC (permalink / raw)
  To: u-boot; +Cc: sbabic, Marek Vasut, Peter Chen, Li Jun, Peng Fan

The ci_req->hw_buf can be NULL, test whether it is and if so,
avoid accessing it. Else, the system may crash.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Peter Chen <peter.chen@nxp.com>
Cc: Li Jun <jun.li@nxp.com>
Cc: Peng Fan <peng.fan@nxp.com>
---
 drivers/usb/gadget/ci_udc.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/ci_udc.c b/drivers/usb/gadget/ci_udc.c
index 226a9e6d671..542684c1c30 100644
--- a/drivers/usb/gadget/ci_udc.c
+++ b/drivers/usb/gadget/ci_udc.c
@@ -402,6 +402,9 @@ align:
 
 flush:
 	hwaddr = (unsigned long)ci_req->hw_buf;
+	if (!hwaddr)
+		return 0;
+
 	aligned_used_len = roundup(req->length, ARCH_DMA_MINALIGN);
 	flush_dcache_range(hwaddr, hwaddr + aligned_used_len);
 
@@ -415,7 +418,7 @@ static void ci_debounce(struct ci_req *ci_req, int in)
 	unsigned long hwaddr = (unsigned long)ci_req->hw_buf;
 	uint32_t aligned_used_len;
 
-	if (in)
+	if (in || !hwaddr)
 		return;
 
 	aligned_used_len = roundup(req->actual, ARCH_DMA_MINALIGN);
-- 
2.34.1


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2022-01-28  3:39 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-28  3:39 [PATCH] usb: gadget: ci: Avoid null pointer dereference Marek Vasut

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.