linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Wen Yang <wen.yang99@zte.com.cn>
To: Bernie Thompson <bernie@plugable.com>,
	Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org,
	linux-kernel@vger.kernel.org, zhong.weidong@zte.com.cn,
	Wen Yang <wen.yang99@zte.com.cn>
Subject: [PATCH] udlfb: fix potential NULL pointer dereference in dlfb_usb_probe
Date: Mon, 3 Dec 2018 14:21:25 +0800	[thread overview]
Message-ID: <20181203062125.34880-1-wen.yang99@zte.com.cn> (raw)

This patch fixes a possible null pointer dereference in
dlfb_usb_probe, detected by the semantic patch deref_null.cocci,
with the following warning:

drivers/video/fbdev/udlfb.c:1704:11-15: ERROR: dlfb is NULL but dereferenced.

The following code has potential null pointer references:
1597         /* usb initialization */
1598         dlfb = kzalloc(sizeof(*dlfb), GFP_KERNEL);
1599         if (!dlfb) {
...
1601             goto error;
1602         }
...
1703 error:
1704         if (dlfb->info) {
1705                 dlfb_ops_destroy(dlfb->info);
1706         } else if (dlfb) {
1707                 usb_put_dev(dlfb->udev);
1708                 kfree(dlfb);
1709         }

Signed-off-by: Wen Yang <wen.yang99@zte.com.cn>
CC: Bernie Thompson <bernie@plugable.com>
CC: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
CC: linux-fbdev@vger.kernel.org
CC: dri-devel@lists.freedesktop.org
CC: linux-kernel@vger.kernel.org
---
 drivers/video/fbdev/udlfb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/video/fbdev/udlfb.c b/drivers/video/fbdev/udlfb.c
index 070026a7e55a..df37cfaa2362 100644
--- a/drivers/video/fbdev/udlfb.c
+++ b/drivers/video/fbdev/udlfb.c
@@ -1701,7 +1701,7 @@ static int dlfb_usb_probe(struct usb_interface *intf,
 	return 0;
 
 error:
-	if (dlfb->info) {
+	if (dlfb && dlfb->info) {
 		dlfb_ops_destroy(dlfb->info);
 	} else if (dlfb) {
 		usb_put_dev(dlfb->udev);
-- 
2.19.1


                 reply	other threads:[~2018-12-03  6:22 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20181203062125.34880-1-wen.yang99@zte.com.cn \
    --to=wen.yang99@zte.com.cn \
    --cc=b.zolnierkie@samsung.com \
    --cc=bernie@plugable.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-fbdev@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=zhong.weidong@zte.com.cn \
    /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).