All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] usb: usb251xb: fix to avoid potential NULL pointer dereference
@ 2019-03-18 23:56 ` Aditya Pakki
  0 siblings, 0 replies; 4+ messages in thread
From: Aditya Pakki @ 2019-03-18 23:56 UTC (permalink / raw)
  To: pakki001
  Cc: kjlu, Richard Leitner, Greg Kroah-Hartman, linux-usb, linux-kernel

of_match_device in usb251xb_probe can fail and returns a NULL pointer.
The patch avoids a potential NULL pointer dereference in this scenario.

Signed-off-by: Aditya Pakki <pakki001@umn.edu>
---
 drivers/usb/misc/usb251xb.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/usb/misc/usb251xb.c b/drivers/usb/misc/usb251xb.c
index 4d72b7d1d383..fe5266dc8864 100644
--- a/drivers/usb/misc/usb251xb.c
+++ b/drivers/usb/misc/usb251xb.c
@@ -612,6 +612,8 @@ static int usb251xb_probe(struct usb251xb *hub)
 							   dev);
 	int err;
 
+	if (!of_id)
+		return -ENODEV;
 	if (np) {
 		err = usb251xb_get_ofdata(hub,
 					  (struct usb251xb_data *)of_id->data);
-- 
2.17.1


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

* usb: usb251xb: fix to avoid potential NULL pointer dereference
@ 2019-03-18 23:56 ` Aditya Pakki
  0 siblings, 0 replies; 4+ messages in thread
From: Aditya Pakki @ 2019-03-18 23:56 UTC (permalink / raw)
  To: pakki001
  Cc: kjlu, Richard Leitner, Greg Kroah-Hartman, linux-usb, linux-kernel

of_match_device in usb251xb_probe can fail and returns a NULL pointer.
The patch avoids a potential NULL pointer dereference in this scenario.

Signed-off-by: Aditya Pakki <pakki001@umn.edu>
---
 drivers/usb/misc/usb251xb.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/usb/misc/usb251xb.c b/drivers/usb/misc/usb251xb.c
index 4d72b7d1d383..fe5266dc8864 100644
--- a/drivers/usb/misc/usb251xb.c
+++ b/drivers/usb/misc/usb251xb.c
@@ -612,6 +612,8 @@ static int usb251xb_probe(struct usb251xb *hub)
 							   dev);
 	int err;
 
+	if (!of_id)
+		return -ENODEV;
 	if (np) {
 		err = usb251xb_get_ofdata(hub,
 					  (struct usb251xb_data *)of_id->data);

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

* Re: [PATCH] usb: usb251xb: fix to avoid potential NULL pointer dereference
@ 2019-03-19 13:11   ` Richard Leitner
  0 siblings, 0 replies; 4+ messages in thread
From: Richard Leitner @ 2019-03-19 13:11 UTC (permalink / raw)
  To: Aditya Pakki; +Cc: kjlu, Greg Kroah-Hartman, linux-usb, linux-kernel

On 19/03/2019 00:56, Aditya Pakki wrote:
> of_match_device in usb251xb_probe can fail and returns a NULL pointer.
> The patch avoids a potential NULL pointer dereference in this scenario.
> 
> Signed-off-by: Aditya Pakki <pakki001@umn.edu>
> ---
>   drivers/usb/misc/usb251xb.c | 2 ++
>   1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/usb/misc/usb251xb.c b/drivers/usb/misc/usb251xb.c
> index 4d72b7d1d383..fe5266dc8864 100644
> --- a/drivers/usb/misc/usb251xb.c
> +++ b/drivers/usb/misc/usb251xb.c
> @@ -612,6 +612,8 @@ static int usb251xb_probe(struct usb251xb *hub)
>   							   dev);
>   	int err;
>   
> +	if (!of_id)
> +		return -ENODEV;

Hi Aditya,
thanks for finding this issue!

Nonetheless I'd prefer to change this to not return here but rather do 
something like:

	if (np && of_id) {

So we still may bring up the hub in its default config in scenarios 
without dt/of...

Any comments/objections on that?

regards;Richard.L

>   	if (np) {
>   		err = usb251xb_get_ofdata(hub,
>   					  (struct usb251xb_data *)of_id->data);
> 

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

* usb: usb251xb: fix to avoid potential NULL pointer dereference
@ 2019-03-19 13:11   ` Richard Leitner
  0 siblings, 0 replies; 4+ messages in thread
From: Richard Leitner @ 2019-03-19 13:11 UTC (permalink / raw)
  To: Aditya Pakki; +Cc: kjlu, Greg Kroah-Hartman, linux-usb, linux-kernel

On 19/03/2019 00:56, Aditya Pakki wrote:
> of_match_device in usb251xb_probe can fail and returns a NULL pointer.
> The patch avoids a potential NULL pointer dereference in this scenario.
> 
> Signed-off-by: Aditya Pakki <pakki001@umn.edu>
> ---
>   drivers/usb/misc/usb251xb.c | 2 ++
>   1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/usb/misc/usb251xb.c b/drivers/usb/misc/usb251xb.c
> index 4d72b7d1d383..fe5266dc8864 100644
> --- a/drivers/usb/misc/usb251xb.c
> +++ b/drivers/usb/misc/usb251xb.c
> @@ -612,6 +612,8 @@ static int usb251xb_probe(struct usb251xb *hub)
>   							   dev);
>   	int err;
>   
> +	if (!of_id)
> +		return -ENODEV;

Hi Aditya,
thanks for finding this issue!

Nonetheless I'd prefer to change this to not return here but rather do 
something like:

	if (np && of_id) {

So we still may bring up the hub in its default config in scenarios 
without dt/of...

Any comments/objections on that?

regards;Richard.L

>   	if (np) {
>   		err = usb251xb_get_ofdata(hub,
>   					  (struct usb251xb_data *)of_id->data);
>

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

end of thread, other threads:[~2019-03-19 13:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-18 23:56 [PATCH] usb: usb251xb: fix to avoid potential NULL pointer dereference Aditya Pakki
2019-03-18 23:56 ` Aditya Pakki
2019-03-19 13:11 ` [PATCH] " Richard Leitner
2019-03-19 13:11   ` Richard Leitner

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.