linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] usb: usb251xb: fix to avoid potential NULL pointer dereference
@ 2019-03-19 20:26 Aditya Pakki
  2019-03-20 10:00 ` Richard Leitner
  0 siblings, 1 reply; 2+ messages in thread
From: Aditya Pakki @ 2019-03-19 20:26 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.

--
v1: Fix to avoid return in case of error, per Richard's suggestion.
Signed-off-by: Aditya Pakki <pakki001@umn.edu>
---
 drivers/usb/misc/usb251xb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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


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

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

Hi, thanks for the updated patch.

Please find my comments below.

On 19/03/2019 21:26, 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.
> 
> --

This should be 3 dashes "---" ;-)

> v1: Fix to avoid return in case of error, per Richard's suggestion.
> Signed-off-by: Aditya Pakki <pakki001@umn.edu>

This signed-off-by line should be in the commit message, not the 
"version history" which is not included in the commit.

Apart from that (if you send a fixed v3) feel free to add
	Reviewed-by: Richard Leitner <richard.leitner@skidata.com>

regards;Richard.L

> ---
>   drivers/usb/misc/usb251xb.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/misc/usb251xb.c b/drivers/usb/misc/usb251xb.c
> index 4d72b7d1d383..bbfdb7447d6f 100644
> --- a/drivers/usb/misc/usb251xb.c
> +++ b/drivers/usb/misc/usb251xb.c
> @@ -612,7 +612,7 @@ static int usb251xb_probe(struct usb251xb *hub)
>   							   dev);
>   	int err;
>   
> -	if (np) {
> +	if (np && of_id) {
>   		err = usb251xb_get_ofdata(hub,
>   					  (struct usb251xb_data *)of_id->data);
>   		if (err) {
> 

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

end of thread, other threads:[~2019-03-20 10:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-19 20:26 [PATCH v2] usb: usb251xb: fix to avoid potential NULL pointer dereference Aditya Pakki
2019-03-20 10:00 ` Richard Leitner

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