[PATCH] usb: host: ohci-tmio: check return value after calling platform_get_resource()

Subsystems: the rest, usb ohci driver, usb subsystem

STALE1792d

2 messages, 2 authors, 2021-09-15 · open the first message on its own page

[PATCH] usb: host: ohci-tmio: check return value after calling platform_get_resource()

From: Yang Yingliang <hidden>
Date: 2021-09-15 03:40:39

It will cause null-ptr-deref if platform_get_resource() returns NULL,
we need check the return value.

Signed-off-by: Yang Yingliang <redacted>
---
 drivers/usb/host/ohci-tmio.c | 3 +++
 1 file changed, 3 insertions(+)
diff --git a/drivers/usb/host/ohci-tmio.c b/drivers/usb/host/ohci-tmio.c
index 08ec2ab0d95a..68e769b82061 100644
--- a/drivers/usb/host/ohci-tmio.c
+++ b/drivers/usb/host/ohci-tmio.c
@@ -202,6 +202,9 @@ static int ohci_hcd_tmio_drv_probe(struct platform_device *dev)
 	if (!cell)
 		return -EINVAL;
 
+	if (!regs || !config || !sram)
+		return -EINVAL;
+
 	if (irq < 0)
 		return irq;
 
-- 
2.25.1

Re: [PATCH] usb: host: ohci-tmio: check return value after calling platform_get_resource()

From: Alan Stern <stern@rowland.harvard.edu>
Date: 2021-09-15 14:11:09

On Wed, Sep 15, 2021 at 11:45:44AM +0800, Yang Yingliang wrote:
quoted hunk
It will cause null-ptr-deref if platform_get_resource() returns NULL,
we need check the return value.

Signed-off-by: Yang Yingliang <redacted>
---
 drivers/usb/host/ohci-tmio.c | 3 +++
 1 file changed, 3 insertions(+)
diff --git a/drivers/usb/host/ohci-tmio.c b/drivers/usb/host/ohci-tmio.c
index 08ec2ab0d95a..68e769b82061 100644
--- a/drivers/usb/host/ohci-tmio.c
+++ b/drivers/usb/host/ohci-tmio.c
@@ -202,6 +202,9 @@ static int ohci_hcd_tmio_drv_probe(struct platform_device *dev)
 	if (!cell)
 		return -EINVAL;
 
+	if (!regs || !config || !sram)
+		return -EINVAL;
Why don't you combine this test with the test immediately above it?

Alan Stern
+
 	if (irq < 0)
 		return irq;
 
-- 
2.25.1
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help