From patchwork Fri Nov 9 20:25:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Khoroshilov X-Patchwork-Id: 10677735 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 03AD613AD for ; Sun, 11 Nov 2018 16:27:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E8A3C2A600 for ; Sun, 11 Nov 2018 16:27:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DD39E2A610; Sun, 11 Nov 2018 16:27:07 +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=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id BCFAF2A600 for ; Sun, 11 Nov 2018 16:27:06 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1C54889F8E; Sun, 11 Nov 2018 16:26:56 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org X-Greylist: delayed 323 seconds by postgrey-1.36 at gabe; Fri, 09 Nov 2018 20:30:46 UTC Received: from mail.ispras.ru (mail.ispras.ru [83.149.199.45]) by gabe.freedesktop.org (Postfix) with ESMTP id A68A76E08F for ; Fri, 9 Nov 2018 20:30:46 +0000 (UTC) Received: from localhost.localdomain (unknown [85.140.188.106]) by mail.ispras.ru (Postfix) with ESMTPSA id 438155400FB; Fri, 9 Nov 2018 23:25:20 +0300 (MSK) From: Alexey Khoroshilov To: Mikulas Patocka , Bernie Thompson , Bartlomiej Zolnierkiewicz Subject: [PATCH] udlfb: fix NULL pointer dereference in dlfb_usb_probe() Date: Fri, 9 Nov 2018 23:25:10 +0300 Message-Id: <1541795110-3179-1-git-send-email-khoroshilov@ispras.ru> X-Mailer: git-send-email 2.7.4 X-Mailman-Approved-At: Sun, 11 Nov 2018 16:26:54 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: ldv-project@linuxtesting.org, linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, Alexey Khoroshilov , linux-kernel@vger.kernel.org MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 Fixes: 68a958a915ca ("udlfb: handle unplug properly") Reviewed-by: Mikulas Patocka --- 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);