linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] usb: host: ohci-tmio: check return value after calling platform_get_resource()
@ 2021-09-15  3:45 Yang Yingliang
  2021-09-15 14:11 ` Alan Stern
  0 siblings, 1 reply; 2+ messages in thread
From: Yang Yingliang @ 2021-09-15  3:45 UTC (permalink / raw)
  To: linux-kernel, linux-usb; +Cc: gregkh, stern

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

Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
 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


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

* Re: [PATCH] usb: host: ohci-tmio: check return value after calling platform_get_resource()
  2021-09-15  3:45 [PATCH] usb: host: ohci-tmio: check return value after calling platform_get_resource() Yang Yingliang
@ 2021-09-15 14:11 ` Alan Stern
  0 siblings, 0 replies; 2+ messages in thread
From: Alan Stern @ 2021-09-15 14:11 UTC (permalink / raw)
  To: Yang Yingliang; +Cc: linux-kernel, linux-usb, gregkh

On Wed, Sep 15, 2021 at 11:45:44AM +0800, Yang Yingliang wrote:
> It will cause null-ptr-deref if platform_get_resource() returns NULL,
> we need check the return value.
> 
> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
> ---
>  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
> 

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

end of thread, other threads:[~2021-09-15 14:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-15  3:45 [PATCH] usb: host: ohci-tmio: check return value after calling platform_get_resource() Yang Yingliang
2021-09-15 14:11 ` Alan Stern

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).