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: 10676551 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 22785109C for ; Fri, 9 Nov 2018 20:25:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0BB702F1DA for ; Fri, 9 Nov 2018 20:25:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F32E42F221; Fri, 9 Nov 2018 20:25:24 +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.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI,SUBJ_OBFU_PUNCT_FEW 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 0DEA42F1DA for ; Fri, 9 Nov 2018 20:25:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725872AbeKJGHd (ORCPT ); Sat, 10 Nov 2018 01:07:33 -0500 Received: from mail.ispras.ru ([83.149.199.45]:37656 "EHLO mail.ispras.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725799AbeKJGHd (ORCPT ); Sat, 10 Nov 2018 01:07:33 -0500 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 Cc: Alexey Khoroshilov , linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, ldv-project@linuxtesting.org 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 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 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);