Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp527372pxx; Wed, 28 Oct 2020 10:19:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxugxD1suKIeQ5Dz3GjSsI8rGW70CEeYPQnyIq+OCkJt++FickVGV3qfyse1n5BhKF7ap1K X-Received: by 2002:a17:907:40c2:: with SMTP id nv2mr62482ejb.337.1603905586820; Wed, 28 Oct 2020 10:19:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603905586; cv=none; d=google.com; s=arc-20160816; b=TE3agYFdxzkAf419O40vnZ/bHdebDDzja5cAPCJFEPQh65PPMu3uXqmdHI5d4L1E5Y SI6JemIH5Y+0B9rPNgGQwlGh9FPf7P64IhndiVU9gRl7vWVeNE3INhwWb1kZYUoXbfPB /We3FtE2/4+vndqwcaCvvLIF6EyNu7VQUnR0ZqeI21adu0sa7pO32hhyT0D9MoGbmug0 e0RSK97OriDgFmsshur7lH75Z52CNwSUYNInmksZ6rwt2ZghxJDJA97yFIQzhkEEuK+o p7CpI1gTpTzYxK34G2BDWi1eNjUYJiFdw9zwuemmAdwq8fDGlU0tX5ojnk7o3/v0Es1g c++w== 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=pwB+sEoyss3hJQf/kTCstJB2A1WC2ESowh91e6yMIrw=; b=SqTSGPIWrggIaiEKIAujYkAf3ucq1I3aClMBEILJUSqm1NPQepBSLi77ebGRcnSFpc +6/nnpQ/0T0d1Xr4UE7jNr5j05QfxSd7Df3Ys7PCaKZdaurfik7ptdmSwl7/QGLODcjk fE5Igfy9+CWxryExDNfGe55fz6OCnk3eWFtz8cKOwzr7YFlGXJHfqfleU/LUJixhDkDd kh6GnaCZyRDYZq3FKgVSZathek1fuFUPzOG89FXrgfhCtzIW5p3zab+o2FXhT2hTXtLM n5bB++UTUbz5NUbZ08HAuSKATNi0PhlQKgA8KInLcOcp+JWoNrHhQsVuh/3kB/OUyZJP RW7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=1OGP7Tdd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y1si30775edp.57.2020.10.28.10.19.23; Wed, 28 Oct 2020 10:19:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=1OGP7Tdd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1820809AbgJ0Riq (ORCPT + 99 others); Tue, 27 Oct 2020 13:38:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:33296 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760308AbgJ0Oeb (ORCPT ); Tue, 27 Oct 2020 10:34:31 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id CB1AD207BB; Tue, 27 Oct 2020 14:34:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603809270; bh=JZO0FMmtG4vn/Ir8BKBtAao/jx/uemYfhrNZ6ukyQ5c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1OGP7TddV5c4rFM6HNflsIwsdwhfa3D6IvsLs9RjGvw8xMWOIjcGZ9I6A66L7azxy jjZI3bUDIB2aQpqQGDfcsXQUntsMy53p/mnwPglflIXoWFkF5sE+NLQfhllVHYqPjk iIiqvhgNYVd5+g+E327qeeNeEtGeRMapd2QRbUtU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tom Rix , Thomas Winischhofer , Andrew Morton , Bartlomiej Zolnierkiewicz , Sasha Levin Subject: [PATCH 5.4 136/408] video: fbdev: sis: fix null ptr dereference Date: Tue, 27 Oct 2020 14:51:14 +0100 Message-Id: <20201027135501.404525918@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135455.027547757@linuxfoundation.org> References: <20201027135455.027547757@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tom Rix [ Upstream commit ad6f93e9cd56f0b10e9b22e3e137d17a1a035242 ] Clang static analysis reports this representative error init.c:2501:18: warning: Array access (from variable 'queuedata') results in a null pointer dereference templ |= ((queuedata[i] & 0xc0) << 3); This is the problem block of code if(ModeNo > 0x13) { ... if(SiS_Pr->ChipType == SIS_730) { queuedata = &FQBQData730[0]; } else { queuedata = &FQBQData[0]; } } else { } queuedata is not set in the else block Reviewing the old code, the arrays FQBQData730 and FQBQData were used directly. So hoist the setting of queuedata out of the if-else block. Fixes: 544393fe584d ("[PATCH] sisfb update") Signed-off-by: Tom Rix Cc: Thomas Winischhofer Cc: Andrew Morton Signed-off-by: Bartlomiej Zolnierkiewicz Link: https://patchwork.freedesktop.org/patch/msgid/20200805145208.17727-1-trix@redhat.com Signed-off-by: Sasha Levin --- drivers/video/fbdev/sis/init.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/video/fbdev/sis/init.c b/drivers/video/fbdev/sis/init.c index dfe3eb769638b..fde27feae5d0c 100644 --- a/drivers/video/fbdev/sis/init.c +++ b/drivers/video/fbdev/sis/init.c @@ -2428,6 +2428,11 @@ SiS_SetCRT1FIFO_630(struct SiS_Private *SiS_Pr, unsigned short ModeNo, i = 0; + if (SiS_Pr->ChipType == SIS_730) + queuedata = &FQBQData730[0]; + else + queuedata = &FQBQData[0]; + if(ModeNo > 0x13) { /* Get VCLK */ @@ -2445,12 +2450,6 @@ SiS_SetCRT1FIFO_630(struct SiS_Private *SiS_Pr, unsigned short ModeNo, /* Get half colordepth */ colorth = colortharray[(SiS_Pr->SiS_ModeType - ModeEGA)]; - if(SiS_Pr->ChipType == SIS_730) { - queuedata = &FQBQData730[0]; - } else { - queuedata = &FQBQData[0]; - } - do { templ = SiS_CalcDelay2(SiS_Pr, queuedata[i]) * VCLK * colorth; -- 2.25.1