linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] udlfb: fix NULL pointer dereference in dlfb_usb_probe()
@ 2018-11-09 20:25 Alexey Khoroshilov
  2018-11-12 14:24 ` Mikulas Patocka
  0 siblings, 1 reply; 2+ messages in thread
From: Alexey Khoroshilov @ 2018-11-09 20:25 UTC (permalink / raw)
  To: Mikulas Patocka, Bernie Thompson, Bartlomiej Zolnierkiewicz
  Cc: Alexey Khoroshilov, linux-fbdev, dri-devel, linux-kernel, ldv-project

If memory allocation for dlfb fails, error handling code
unconditionally dereference NULL pointer.

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
Fixes: 68a958a915ca ("udlfb: handle unplug properly")
---
 drivers/video/fbdev/udlfb.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/video/fbdev/udlfb.c b/drivers/video/fbdev/udlfb.c
index 070026a7e55a..9643fe7c8349 100644
--- a/drivers/video/fbdev/udlfb.c
+++ b/drivers/video/fbdev/udlfb.c
@@ -1590,7 +1590,7 @@ static int dlfb_usb_probe(struct usb_interface *intf,
 	int i;
 	const struct device_attribute *attr;
 	struct dlfb_data *dlfb;
-	struct fb_info *info;
+	struct fb_info *info = NULL;
 	int retval = -ENOMEM;
 	struct usb_device *usbdev = interface_to_usbdev(intf);
 
@@ -1701,8 +1701,8 @@ static int dlfb_usb_probe(struct usb_interface *intf,
 	return 0;
 
 error:
-	if (dlfb->info) {
-		dlfb_ops_destroy(dlfb->info);
+	if (info) {
+		dlfb_ops_destroy(info);
 	} else if (dlfb) {
 		usb_put_dev(dlfb->udev);
 		kfree(dlfb);
-- 
2.7.4


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

* Re: [PATCH] udlfb: fix NULL pointer dereference in dlfb_usb_probe()
  2018-11-09 20:25 [PATCH] udlfb: fix NULL pointer dereference in dlfb_usb_probe() Alexey Khoroshilov
@ 2018-11-12 14:24 ` Mikulas Patocka
  0 siblings, 0 replies; 2+ messages in thread
From: Mikulas Patocka @ 2018-11-12 14:24 UTC (permalink / raw)
  To: Alexey Khoroshilov
  Cc: Bernie Thompson, Bartlomiej Zolnierkiewicz, linux-fbdev,
	dri-devel, linux-kernel, ldv-project



On Fri, 9 Nov 2018, Alexey Khoroshilov wrote:

> If memory allocation for dlfb fails, error handling code
> unconditionally dereference NULL pointer.
> 
> Found by Linux Driver Verification project (linuxtesting.org).
> 
> Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
> Fixes: 68a958a915ca ("udlfb: handle unplug properly")

Reviewed-by: Mikulas Patocka <mpatocka@redhat.com>

> ---
>  drivers/video/fbdev/udlfb.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/video/fbdev/udlfb.c b/drivers/video/fbdev/udlfb.c
> index 070026a7e55a..9643fe7c8349 100644
> --- a/drivers/video/fbdev/udlfb.c
> +++ b/drivers/video/fbdev/udlfb.c
> @@ -1590,7 +1590,7 @@ static int dlfb_usb_probe(struct usb_interface *intf,
>  	int i;
>  	const struct device_attribute *attr;
>  	struct dlfb_data *dlfb;
> -	struct fb_info *info;
> +	struct fb_info *info = NULL;
>  	int retval = -ENOMEM;
>  	struct usb_device *usbdev = interface_to_usbdev(intf);
>  
> @@ -1701,8 +1701,8 @@ static int dlfb_usb_probe(struct usb_interface *intf,
>  	return 0;
>  
>  error:
> -	if (dlfb->info) {
> -		dlfb_ops_destroy(dlfb->info);
> +	if (info) {
> +		dlfb_ops_destroy(info);
>  	} else if (dlfb) {
>  		usb_put_dev(dlfb->udev);
>  		kfree(dlfb);
> -- 
> 2.7.4
> 

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

end of thread, other threads:[~2018-11-12 14:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-09 20:25 [PATCH] udlfb: fix NULL pointer dereference in dlfb_usb_probe() Alexey Khoroshilov
2018-11-12 14:24 ` Mikulas Patocka

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