linux-fbdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] video: fbdev: udlfb: Fix use after free on dlfb_usb_probe error path
@ 2017-08-11 12:59 ` Anton Vasilyev
  2017-08-21 14:35   ` Bartlomiej Zolnierkiewicz
  0 siblings, 1 reply; 2+ messages in thread
From: Anton Vasilyev @ 2017-08-11 12:59 UTC (permalink / raw)
  To: Bernie Thompson
  Cc: Anton Vasilyev, Bartlomiej Zolnierkiewicz, linux-fbdev,
	linux-kernel, ldv-project

If dlfb_usb_probe drops to error path then there is only one
kref_init() call and no kref_get(), so second kref_put() leads to
use after free.

The patch removes superfluous kref_put on dlfb_usb_probe error path.

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

Signed-off-by: Anton Vasilyev <vasilyev@ispras.ru>
---
 drivers/video/fbdev/udlfb.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/video/fbdev/udlfb.c b/drivers/video/fbdev/udlfb.c
index 05ef657..f71b49f 100644
--- a/drivers/video/fbdev/udlfb.c
+++ b/drivers/video/fbdev/udlfb.c
@@ -1655,7 +1655,6 @@ static int dlfb_usb_probe(struct usb_interface *interface,
 error:
 	if (dev) {
 
-		kref_put(&dev->kref, dlfb_free); /* ref for framebuffer */
 		kref_put(&dev->kref, dlfb_free); /* last ref from kref_init */
 
 		/* dev has been deallocated. Do not dereference */
-- 
2.7.4


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

* Re: [PATCH] video: fbdev: udlfb: Fix use after free on dlfb_usb_probe error path
  2017-08-11 12:59 ` [PATCH] video: fbdev: udlfb: Fix use after free on dlfb_usb_probe error path Anton Vasilyev
@ 2017-08-21 14:35   ` Bartlomiej Zolnierkiewicz
  0 siblings, 0 replies; 2+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2017-08-21 14:35 UTC (permalink / raw)
  To: Anton Vasilyev; +Cc: Bernie Thompson, linux-fbdev, linux-kernel, ldv-project

On Friday, August 11, 2017 03:59:01 PM Anton Vasilyev wrote:
> If dlfb_usb_probe drops to error path then there is only one
> kref_init() call and no kref_get(), so second kref_put() leads to
> use after free.
> 
> The patch removes superfluous kref_put on dlfb_usb_probe error path.
> 
> Found by Linux Driver Verification project (linuxtesting.org).
> 
> Signed-off-by: Anton Vasilyev <vasilyev@ispras.ru>

Patch queued for 4.14, thanks.

Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics


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

end of thread, other threads:[~2017-08-21 14:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <CGME20170811125917epcas4p1201e8047f04655c0cade9d0b92c0fd30@epcas4p1.samsung.com>
2017-08-11 12:59 ` [PATCH] video: fbdev: udlfb: Fix use after free on dlfb_usb_probe error path Anton Vasilyev
2017-08-21 14:35   ` Bartlomiej Zolnierkiewicz

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