linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] usb: phy: am335x-control: check return value of bus_find_device
@ 2015-02-08 15:29 David Dueck
  2015-02-08 16:03 ` Sebastian Andrzej Siewior
  0 siblings, 1 reply; 2+ messages in thread
From: David Dueck @ 2015-02-08 15:29 UTC (permalink / raw)
  To: linux-kernel; +Cc: bigeasy, balbi, gregkh, linux-usb

This fixes a potential null pointer dereference.

Signed-off-by: David Dueck <davidcdueck@googlemail.com>
---
 drivers/usb/phy/phy-am335x-control.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/usb/phy/phy-am335x-control.c b/drivers/usb/phy/phy-am335x-control.c
index 403fab7..7b3035f 100644
--- a/drivers/usb/phy/phy-am335x-control.c
+++ b/drivers/usb/phy/phy-am335x-control.c
@@ -126,6 +126,9 @@ struct phy_control *am335x_get_phy_control(struct device *dev)
 		return NULL;
 
 	dev = bus_find_device(&platform_bus_type, NULL, node, match);
+	if (!dev)
+		return NULL;
+
 	ctrl_usb = dev_get_drvdata(dev);
 	if (!ctrl_usb)
 		return NULL;
-- 
2.2.2


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

* Re: [PATCH] usb: phy: am335x-control: check return value of bus_find_device
  2015-02-08 15:29 [PATCH] usb: phy: am335x-control: check return value of bus_find_device David Dueck
@ 2015-02-08 16:03 ` Sebastian Andrzej Siewior
  0 siblings, 0 replies; 2+ messages in thread
From: Sebastian Andrzej Siewior @ 2015-02-08 16:03 UTC (permalink / raw)
  To: David Dueck, linux-kernel, gregkh; +Cc: balbi, linux-usb

On 02/08/2015 04:29 PM, David Dueck wrote:
> This fixes a potential null pointer dereference.
> 
> Signed-off-by: David Dueck <davidcdueck@googlemail.com>

Acked-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Fixes: d4332013919a ("driver core: dev_get_drvdata: Don't check for NULL
dev")

Greg, this is a regression since d43320139 ("driver core:
dev_get_drvdata: Don't check for NULL dev"). I didn't check for NULL
after bus_find_device() because I knew that dev_get_drvdata() will do
it.

> ---
>  drivers/usb/phy/phy-am335x-control.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/usb/phy/phy-am335x-control.c b/drivers/usb/phy/phy-am335x-control.c
> index 403fab7..7b3035f 100644
> --- a/drivers/usb/phy/phy-am335x-control.c
> +++ b/drivers/usb/phy/phy-am335x-control.c
> @@ -126,6 +126,9 @@ struct phy_control *am335x_get_phy_control(struct device *dev)
>  		return NULL;
>  
>  	dev = bus_find_device(&platform_bus_type, NULL, node, match);
> +	if (!dev)
> +		return NULL;
> +
>  	ctrl_usb = dev_get_drvdata(dev)
>  	if (!ctrl_usb)
>  		return NULL;
> 

Sebastian

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

end of thread, other threads:[~2015-02-08 16:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-08 15:29 [PATCH] usb: phy: am335x-control: check return value of bus_find_device David Dueck
2015-02-08 16:03 ` Sebastian Andrzej Siewior

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).