udlfb: don't call unregister_framebuffer on a null pointer

Submitted by Colin King on Nov. 24, 2018, 2:48 p.m.

Details

Message ID 20181124144840.14608-1-colin.king@canonical.com
State New
Headers show
Series "udlfb: don't call unregister_framebuffer on a null pointer" ( rev: 1 ) in DRI devel

Not browsing as part of any series.

Commit Message

Colin King Nov. 24, 2018, 2:48 p.m.
From: Colin Ian King <colin.king@canonical.com>

Just before calling unregister_framebuffer with info there is a
null check on info, implying info may possibly zero.  Calling
unregister_framebuffer with a null pointer will cause a null
pointer dereference, fix this by moving the call to the block
where info has been null checked.

Detected by CoverityScan, CID#1473969 ("Dereference after null check")

Fixes: 68a958a915ca ("udlfb: handle unplug properly")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/video/fbdev/udlfb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/drivers/video/fbdev/udlfb.c b/drivers/video/fbdev/udlfb.c
index 070026a7e55a..cf8597f43d7e 100644
--- a/drivers/video/fbdev/udlfb.c
+++ b/drivers/video/fbdev/udlfb.c
@@ -1735,9 +1735,9 @@  static void dlfb_usb_disconnect(struct usb_interface *intf)
 		for (i = 0; i < ARRAY_SIZE(fb_device_attrs); i++)
 			device_remove_file(info->dev, &fb_device_attrs[i]);
 		device_remove_bin_file(info->dev, &edid_attr);
+		unregister_framebuffer(info);
 	}
 
-	unregister_framebuffer(info);
 }
 
 static struct usb_driver dlfb_driver = {