Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp3520830pxb; Tue, 19 Apr 2022 04:36:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzwy9/5WFfmDyfwdvSZWJsKBs0BMOcdVNNQ5lQ4dO9Oywqg49ixDWrijTQt52W2JCFiFLqA X-Received: by 2002:a17:90a:e7cd:b0:1c7:acbd:215d with SMTP id kb13-20020a17090ae7cd00b001c7acbd215dmr18066942pjb.153.1650368189925; Tue, 19 Apr 2022 04:36:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650368189; cv=none; d=google.com; s=arc-20160816; b=NGGricAujSI9Zbt/w/mUs9ajFzI0APjZPZeuQCFbB5aoprXPCCy5RBIe4ye4lLOAQH hz2xBFTBEI0gdDRq9ogjQ/dB6nBzymjyjEq8AI/n0etCRcW4dkosLtzOv7bt0JJx8LZF N9+CyMWwU+TwoegtfE0av96cT/kJkckCGB36hd8oCJXpJe7UXa8kc1kch+YZZL7qKsy0 ZRr6p7hEHr8DmQADNHDiEesFuH9Kvq9RSsdkqeSJcgsnVmLDkAhqVB7YhoDrTnYaDjxe GnvzqE1CugceUSCWV7PFSm3XIQQzAJ5UHFNUlL12IcoBkG8xdMd2a/w37fRGjGtXNvGP 8c6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=iXbKQ+AnKXrPGHk4+x6F2MNOGHa7yOnUv75pGUDm54k=; b=vP8d2hFdmcq2rS09WWLmtkeelW3Gja2R8iyTXXwZSn14D4hsm5mUoRCpQbgovIl/oz TY5i+sni0rB9tk7h/j0e0rJZi74wAy3akkWbQZCE1eYOL9ua6MNdsz+H7yX0GXSQrWKz 6CgHnc2hMvQyLGGPAA3GOp1TXEh0E6ZcrVugO5a/RFAHaIoWVEQgBrmNM2owha5kCObF Idh7lqd/EPlx26YYUItuP6Dkr1EIvsY787mpLL3DPtdpLE3Ry6AVib2I5GmD/MbBEMlw RK7xun2i3x5hMKt76kIBhTmwz5XLL8rVy4azAY4hq8zw5jL33yTajNOTRigjIX7c0I6v gVlA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=wSi5utzh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id mu9-20020a17090b388900b001d2ae6f906bsi2196938pjb.9.2022.04.19.04.36.15; Tue, 19 Apr 2022 04:36:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=wSi5utzh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243221AbiDRNkE (ORCPT + 99 others); Mon, 18 Apr 2022 09:40:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235578AbiDRNMC (ORCPT ); Mon, 18 Apr 2022 09:12:02 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 55ED92D1F4; Mon, 18 Apr 2022 05:50:45 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 011C3B80E4B; Mon, 18 Apr 2022 12:50:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 40E1EC385A7; Mon, 18 Apr 2022 12:50:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1650286242; bh=FsWshQH8zkPlqgJV6Rgm23aYYDRNwTmQRak3RDzTGdo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wSi5utzhqlLOxnlKPWbb132ee0tOb3aJLPytlEaunoavux73i9fHxGDlx91FI13qy sLpC6sdH0WHvLpHSACacVenaMEQKARMBsH8LkcQgR0nVBXAVupvh35pvdUUXk0IMVh On3suFrkr+mQxtWGYLDhjb0D+mxne1RoJZpk7sIs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hulk Robot , Wang Hai , Thomas Zimmermann , Helge Deller , Sasha Levin Subject: [PATCH 4.14 072/284] video: fbdev: smscufx: Fix null-ptr-deref in ufx_usb_probe() Date: Mon, 18 Apr 2022 14:10:53 +0200 Message-Id: <20220418121212.735308807@linuxfoundation.org> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220418121210.689577360@linuxfoundation.org> References: <20220418121210.689577360@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Wang Hai [ Upstream commit 1791f487f877a9e83d81c8677bd3e7b259e7cb27 ] I got a null-ptr-deref report: BUG: kernel NULL pointer dereference, address: 0000000000000000 ... RIP: 0010:fb_destroy_modelist+0x38/0x100 ... Call Trace: ufx_usb_probe.cold+0x2b5/0xac1 [smscufx] usb_probe_interface+0x1aa/0x3c0 [usbcore] really_probe+0x167/0x460 ... ret_from_fork+0x1f/0x30 If fb_alloc_cmap() fails in ufx_usb_probe(), fb_destroy_modelist() will be called to destroy modelist in the error handling path. But modelist has not been initialized yet, so it will result in null-ptr-deref. Initialize modelist before calling fb_alloc_cmap() to fix this bug. Fixes: 3c8a63e22a08 ("Add support for SMSC UFX6000/7000 USB display adapters") Reported-by: Hulk Robot Signed-off-by: Wang Hai Acked-by: Thomas Zimmermann Signed-off-by: Helge Deller Signed-off-by: Sasha Levin --- drivers/video/fbdev/smscufx.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/video/fbdev/smscufx.c b/drivers/video/fbdev/smscufx.c index 2275e80b5776..1b244bea24b8 100644 --- a/drivers/video/fbdev/smscufx.c +++ b/drivers/video/fbdev/smscufx.c @@ -1672,6 +1672,7 @@ static int ufx_usb_probe(struct usb_interface *interface, info->par = dev; info->pseudo_palette = dev->pseudo_palette; info->fbops = &ufx_ops; + INIT_LIST_HEAD(&info->modelist); retval = fb_alloc_cmap(&info->cmap, 256, 0); if (retval < 0) { @@ -1682,8 +1683,6 @@ static int ufx_usb_probe(struct usb_interface *interface, INIT_DELAYED_WORK(&dev->free_framebuffer_work, ufx_free_framebuffer_work); - INIT_LIST_HEAD(&info->modelist); - retval = ufx_reg_read(dev, 0x3000, &id_rev); check_warn_goto_error(retval, "error %d reading 0x3000 register from device", retval); dev_dbg(dev->gdev, "ID_REV register value 0x%08x", id_rev); -- 2.34.1