usb: usb251xb: fix to avoid potential NULL pointer dereference
authorAditya Pakki <pakki001@umn.edu>
Wed, 20 Mar 2019 15:27:11 +0000 (10:27 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 4 May 2019 07:20:20 +0000 (09:20 +0200)
[ Upstream commit 41f00e6e9e55546390031996b773e7f3c1d95928 ]

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>
Reviewed-by: Richard Leitner <richard.leitner@skidata.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin (Microsoft) <sashal@kernel.org>
drivers/usb/misc/usb251xb.c

index a6efb9a..5f7734c 100644 (file)
@@ -601,7 +601,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) {