linux-fbdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Anton Vasilyev <vasilyev@ispras.ru>
To: Bernie Thompson <bernie@plugable.com>
Cc: Anton Vasilyev <vasilyev@ispras.ru>,
	Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>,
	linux-fbdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	ldv-project@linuxtesting.org
Subject: [PATCH] video: fbdev: udlfb: Fix use after free on dlfb_usb_probe error path
Date: Fri, 11 Aug 2017 12:59:01 +0000	[thread overview]
Message-ID: <1502456341-1783-1-git-send-email-vasilyev@ispras.ru> (raw)

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


             reply	other threads:[~2017-08-11 12:59 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20170811125917epcas4p1201e8047f04655c0cade9d0b92c0fd30@epcas4p1.samsung.com>
2017-08-11 12:59 ` Anton Vasilyev [this message]
2017-08-21 14:35   ` [PATCH] video: fbdev: udlfb: Fix use after free on dlfb_usb_probe error path Bartlomiej Zolnierkiewicz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1502456341-1783-1-git-send-email-vasilyev@ispras.ru \
    --to=vasilyev@ispras.ru \
    --cc=b.zolnierkie@samsung.com \
    --cc=bernie@plugable.com \
    --cc=ldv-project@linuxtesting.org \
    --cc=linux-fbdev@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).