[PATCH] usb: ohci-hcd: Null check lurb_priv before dereference

Andrew Goodbody andrew.goodbody at linaro.org
Tue Sep 30 11:56:02 CEST 2025


When a variable needs a null check before it is dreferenced ensure that
this is done even in the case of assignment on declaration. This was not
happening for lurb_priv so correct it.

This issue was found by Smatch.

Signed-off-by: Andrew Goodbody <andrew.goodbody at linaro.org>
---
 drivers/usb/host/ohci-hcd.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c
index 234a6f3645d15d72f93eda2ca6945fb16aaa9adb..1d6711ccec43cfd40f6a1e066035089222fa8ebc 100644
--- a/drivers/usb/host/ohci-hcd.c
+++ b/drivers/usb/host/ohci-hcd.c
@@ -1040,9 +1040,11 @@ static void dl_transfer_length(td_t *td)
 static void check_status(td_t *td_list)
 {
 	urb_priv_t *lurb_priv = td_list->ed->purb;
-	int	   urb_len    = lurb_priv->length;
 	__u32      *phwHeadP  = &td_list->ed->hwHeadP;
-	int	   cc;
+	int	   cc, urb_len;
+
+	if (lurb_priv)
+		urb_len = lurb_priv->length;
 
 	cc = TD_CC_GET(m32_swap(td_list->hwINFO));
 	if (cc) {

---
base-commit: 9710d98e8942151fc0c62d54100d9d27e8263d04
change-id: 20250930-usb_ohci-42f61b2439ec

Best regards,
-- 
Andrew Goodbody <andrew.goodbody at linaro.org>



More information about the U-Boot mailing list