Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp673683pxb; Tue, 5 Apr 2022 18:13:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxmZBtI58F8Ngt/G2V+UKRktp9YnZgWnS93AMDMlDmqsQ1knkjAzpRLJ7yxuVVWlUofQ1Gd X-Received: by 2002:a17:902:ec89:b0:156:c5db:356d with SMTP id x9-20020a170902ec8900b00156c5db356dmr6071100plg.74.1649207615119; Tue, 05 Apr 2022 18:13:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649207615; cv=none; d=google.com; s=arc-20160816; b=e+MAWDwQHIX1k2pin6m4Sf4+RyCc4Wy1XZX1SYs7ROcLKwN/kJVJ2WEn2jiodL/oll 3aZJ6KE9qWPaArhTHe55mMuPWysQ8ghIHbof6MsOLCPt5XE0rOnXIN7fUEF4J9C9nnzX mFHzXTm3j8D+O5wtWJ3prU/Cfh1QAc9gGWiQS6mMVv6CDtPXTKLv1eEfP5PuB3yOsjwl gZghrCoE+GlEqmfYeSD2zKiHE7pZkY9j1Yz5d/Zsxyl2c3Fa0t5X4nKwAo4JZR3T2Nbe Cd+1P6h44WwLL0vTImp1D8DcFqhWTMbaF3aD5r7y324+0ENTGY/EZio93ACQ9GeKyjdx nlYw== 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=Lskp83/DHiLzAd5icQa65dk/tmTvK6LwAiCWp2BZZgo=; b=dIeKIV2eCFwcmb2GUBpwyAQtafCJt53hNXWQN8+Ysv00VFA5lH9ZrgkgoMzOEXWcks IDBPQY4uAW5+Jm90mJEvWJlKr9zPlt9vtz/dgZNNZLpkYolBngbinyxMdjRIah6xh52O R5EPjB+ckeyUOO37lBZX90GkzkTrSUfi3i8xbKrDNaBs2HHHOsX5HmvIxOq/wYOP1sj7 wmUDdrLaatJEA7PIhyV4tucoW+BG4qBRe9aNpGiUac8c1NhuriLMEZvmP6Anvk3VFGC4 J/rxMkK0jndO78oGwnl8yLAC7uqqZUojpurzwNOSFCLsQbgEJed+nv47G25CdW5V+ry9 3cGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=u0plil54; 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 b17-20020a63eb51000000b003816043f0e1si14124030pgk.726.2022.04.05.18.13.20; Tue, 05 Apr 2022 18:13:35 -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=u0plil54; 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 S1348518AbiDELx1 (ORCPT + 99 others); Tue, 5 Apr 2022 07:53:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46808 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244914AbiDEIwr (ORCPT ); Tue, 5 Apr 2022 04:52:47 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 014E324959; Tue, 5 Apr 2022 01:46:09 -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 B071DB81BC5; Tue, 5 Apr 2022 08:46:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 27646C385A0; Tue, 5 Apr 2022 08:46:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649148367; bh=lfMoL5Nyc8RJg1qdgYmPYov80y4msIbqIDeHePByH+4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=u0plil54uYHJSreWpd16iWAQuIHgcI88+clWdFubrPMqWguyHIjGVJsdERw6S2jT1 8+bNmBOP8OdsRo33xXFf60AUxhvMPTkXOV5zdTVW2gy465susz4A1SxR22SZHJZkl6 1jxKdXGPcqbc8uzG1Q77mv6e1+yToqfJ4XSYnNK4= 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 5.16 0304/1017] video: fbdev: smscufx: Fix null-ptr-deref in ufx_usb_probe() Date: Tue, 5 Apr 2022 09:20:17 +0200 Message-Id: <20220405070403.299265539@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070354.155796697@linuxfoundation.org> References: <20220405070354.155796697@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.1 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 bfac3ee4a642..28768c272b73 100644 --- a/drivers/video/fbdev/smscufx.c +++ b/drivers/video/fbdev/smscufx.c @@ -1656,6 +1656,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) { @@ -1666,8 +1667,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