Commit c143a559 authored by Dan Carpenter's avatar Dan Carpenter Committed by Bartlomiej Zolnierkiewicz

udlfb: fix some inconsistent NULL checking

In the current kernel, then kzalloc() can't fail for small allocations,
but if it did fail then we would have a NULL dereference in the error
handling.  Also in dlfb_usb_disconnect() if "info" were NULL then it
would cause an Oops inside the unregister_framebuffer() function but it
can't be NULL so let's remove that check.

Fixes: 68a958a9 ("udlfb: handle unplug properly")
Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Cc: Bernie Thompson <bernie@plugable.com>
Cc: Mikulas Patocka <mpatocka@redhat.com>
Cc: Alexey Khoroshilov <khoroshilov@ispras.ru>
Cc: Colin Ian King <colin.king@canonical.com>
Cc: Wen Yang <wen.yang99@zte.com.cn>
[b.zolnierkie: added "Fixes:" tag]
Signed-off-by: default avatarBartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
parent 31d1b771
...@@ -1598,7 +1598,7 @@ static int dlfb_usb_probe(struct usb_interface *intf, ...@@ -1598,7 +1598,7 @@ static int dlfb_usb_probe(struct usb_interface *intf,
dlfb = kzalloc(sizeof(*dlfb), GFP_KERNEL); dlfb = kzalloc(sizeof(*dlfb), GFP_KERNEL);
if (!dlfb) { if (!dlfb) {
dev_err(&intf->dev, "%s: failed to allocate dlfb\n", __func__); dev_err(&intf->dev, "%s: failed to allocate dlfb\n", __func__);
goto error; return -ENOMEM;
} }
INIT_LIST_HEAD(&dlfb->deferred_free); INIT_LIST_HEAD(&dlfb->deferred_free);
...@@ -1703,7 +1703,7 @@ static int dlfb_usb_probe(struct usb_interface *intf, ...@@ -1703,7 +1703,7 @@ static int dlfb_usb_probe(struct usb_interface *intf,
error: error:
if (dlfb->info) { if (dlfb->info) {
dlfb_ops_destroy(dlfb->info); dlfb_ops_destroy(dlfb->info);
} else if (dlfb) { } else {
usb_put_dev(dlfb->udev); usb_put_dev(dlfb->udev);
kfree(dlfb); kfree(dlfb);
} }
...@@ -1730,12 +1730,10 @@ static void dlfb_usb_disconnect(struct usb_interface *intf) ...@@ -1730,12 +1730,10 @@ static void dlfb_usb_disconnect(struct usb_interface *intf)
/* this function will wait for all in-flight urbs to complete */ /* this function will wait for all in-flight urbs to complete */
dlfb_free_urb_list(dlfb); dlfb_free_urb_list(dlfb);
if (info) { /* remove udlfb's sysfs interfaces */
/* remove udlfb's sysfs interfaces */ for (i = 0; i < ARRAY_SIZE(fb_device_attrs); i++)
for (i = 0; i < ARRAY_SIZE(fb_device_attrs); i++) device_remove_file(info->dev, &fb_device_attrs[i]);
device_remove_file(info->dev, &fb_device_attrs[i]); device_remove_bin_file(info->dev, &edid_attr);
device_remove_bin_file(info->dev, &edid_attr);
}
unregister_framebuffer(info); unregister_framebuffer(info);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment