From patchwork Mon Dec 3 06:21:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wen Yang X-Patchwork-Id: 10708657 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1222A1057 for ; Mon, 3 Dec 2018 06:22:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 03B112AC41 for ; Mon, 3 Dec 2018 06:22:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EBEDD2AC30; Mon, 3 Dec 2018 06:21:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 476E82AC35 for ; Mon, 3 Dec 2018 06:21:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725876AbeLCGWC (ORCPT ); Mon, 3 Dec 2018 01:22:02 -0500 Received: from mxhk.zte.com.cn ([63.217.80.70]:8288 "EHLO mxhk.zte.com.cn" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725824AbeLCGWC (ORCPT ); Mon, 3 Dec 2018 01:22:02 -0500 Received: from mse01.zte.com.cn (unknown [10.30.3.20]) by Forcepoint Email with ESMTPS id EEC02247E69156DC34F0; Mon, 3 Dec 2018 14:21:55 +0800 (CST) Received: from notes_smtp.zte.com.cn ([10.30.1.239]) by mse01.zte.com.cn with ESMTP id wB36LnJ0033684; Mon, 3 Dec 2018 14:21:49 +0800 (GMT-8) (envelope-from wen.yang99@zte.com.cn) Received: from LIN-A6CB96A0603.zte.intra ([10.90.106.118]) by szsmtp06.zte.com.cn (Lotus Domino Release 8.5.3FP6) with ESMTP id 2018120314215533-14385734 ; Mon, 3 Dec 2018 14:21:55 +0800 From: Wen Yang To: Bernie Thompson , Bartlomiej Zolnierkiewicz Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, zhong.weidong@zte.com.cn, Wen Yang Subject: [PATCH] udlfb: fix potential NULL pointer dereference in dlfb_usb_probe Date: Mon, 3 Dec 2018 14:21:25 +0800 Message-Id: <20181203062125.34880-1-wen.yang99@zte.com.cn> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 X-MIMETrack: Itemize by SMTP Server on SZSMTP06/server/zte_ltd(Release 8.5.3FP6|November 21, 2013) at 2018-12-03 14:21:55, Serialize by Router on notes_smtp/zte_ltd(Release 9.0.1FP7|August 17, 2016) at 2018-12-03 14:21:49 X-MAIL: mse01.zte.com.cn wB36LnJ0033684 Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 CC: Bernie Thompson CC: Bartlomiej Zolnierkiewicz 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);