Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp161101pxx; Wed, 28 Oct 2020 01:09:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw67XXmUO+XMMT+bB/wbxBZeM/p2Kd/EgOOS19gA+KGqOWTM57RS/zya3/GLTuL9qqWHPYX X-Received: by 2002:a17:906:4d03:: with SMTP id r3mr5979717eju.364.1603872549461; Wed, 28 Oct 2020 01:09:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603872549; cv=none; d=google.com; s=arc-20160816; b=vMi7NfbWs6Ob1laYMj8+zXK8B4dw6jQND9IvIVsOxdZVNSoOrO1Aklm2do7Oo2iuzE uU/e5C57HNT8GDXSoiAKqIJUNbIke60xzp6wAVpg/faGIAUOQFXiHriPZVT2deYJQ5Ou 3QcbekmG/Cn2CGtRRH0g2SYtw0A0OVQn2GJVG4fLi+oSyhe+HJnEsN/+H1I4kQYeL05x 6IuUOH15sB889jCe3ArH0Y8cz8ZHpegYEiK8GXHb73hTsHf4ng03rGp9H/exQVSVxOOa FjtGyziPhfkBkbRdh0LtK1trsaMsYQND6UEThe0KbEq9wRUtnLuAjTP/0sJ/jxhM5NmX BjNQ== 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=IB8Yrss5tkF4Ghrytp2e3aXAEq0MscPtNG2gJV1V+blOoaILJEmWIW6K/EaTxKRFNr 97Au66FjX71+3blNfREwytl5knxAXNiTHAWnfwralrhw/GOSFww6OYOnzmGhgYrctse+ UJDSwcZ+4ZcqxTAoiSB+QEh0qYm32SeROW44s18GMzyyF4o9Pw0aQTGCAmdPSauOxaF1 e1gzTz5PbGYA2cvP+zApZBiBeahmEUH/X4SatiEqmYPeoaiCfG55fE7gF8vZmzrbSarz wOB0uZFigw7/t6z+f3NSO3+xlHuUeRhxuH3XKVxmHSZoMDkQC/1rmrQ4mnVWFxHSL/F9 e5og== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=bfsAN6ij; 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 w17si2969573ejk.629.2020.10.28.01.08.47; Wed, 28 Oct 2020 01:09:09 -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=bfsAN6ij; 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 S1753056AbgJ0N6S (ORCPT + 99 others); Tue, 27 Oct 2020 09:58:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:45468 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753044AbgJ0N6P (ORCPT ); Tue, 27 Oct 2020 09:58:15 -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 2A452206D4; Tue, 27 Oct 2020 13:58:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603807094; bh=JZO0FMmtG4vn/Ir8BKBtAao/jx/uemYfhrNZ6ukyQ5c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bfsAN6ijlyRcLdthg2N1FIf5oJgd2Na22Z2LY2s+gQmHrvOBmz2hVRPcafZoITFbe mhSEsV3iMeeYj2plXBH9oSR9j7DTCPwxM+IGVErzDbjwd3+1fQOnAkY9FnALvBfkMn SU5SKYUyxh2VRFm7aJBNO9qeoCYHLkRzJ488zwy8= 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 4.4 041/112] video: fbdev: sis: fix null ptr dereference Date: Tue, 27 Oct 2020 14:49:11 +0100 Message-Id: <20201027134902.500435453@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027134900.532249571@linuxfoundation.org> References: <20201027134900.532249571@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