Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp257945pxx; Wed, 28 Oct 2020 04:17:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxSCOdMU1nuXpKUvq99z1gDGp60tk/4X/1T3FA1DdJSWoQ69A/cmfvNiwZbok6GvdI2gWJm X-Received: by 2002:a17:906:35d7:: with SMTP id p23mr4004221ejb.312.1603883863841; Wed, 28 Oct 2020 04:17:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603883863; cv=none; d=google.com; s=arc-20160816; b=uR2Ikt32Q4tPR8WQyieIkSO4INo1buQhkgZcbnEtE6krWhvRT/h1MTpgU22qFz084t Hm0lNRB+J7GrOmBThkQdt4XBvfc6nO0wG2JlW/6CbreuR/map1Xp1wUwy8y6Bw0NjIG8 uRUUUFjt2pF0Mjr7+suncG083g9LBCd2mUDbOe2th4JTOjYHGutwn+rtnClgJMl08ATR NZU7go2DJSRnHdNxhy/nEKWaix95yo0Gof/hGumr3Uj6756upUkKGFMS1oUHnR/qrALf Ojf5Yx+wp4sHPVxkzZ9xziFSZMcban64cYQA9cw8LZiwnpH+qY4xpRvGeA+60mS1OzHl 7lBQ== 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=Otkn8x+R/oEH5a6dvwdNZW2aN3d/rYTwy8xn7UewnYVwenlfieENCbMS8dk7c1NqRU H6g0EZZLOYc+geUO8CmTnrGSYHX4chqlZUgBV3JpllCzhCM1ymm+tVG1O1Q/k15ePJgL iGkQEKaPrPkObxj85vLMfjN+4fYyw0qHHgmqT2XI7AdmchQ2k2b87/3w2Dkf+n1vqXdz qL1KBStoJseZzuqwodwt9dEWvgRBtZtxZ6dZkIGFvDjXeWDRHj3T7ozi9O5hEgJUTWRr d/dJppdcdK1W6fJgLobCgLrFNbr/A33bKi82eY7zvH5hId5LVgAgVbD9JKvldJaUKGXb 6UOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=axkVr+lk; 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 z8si2802677eju.267.2020.10.28.04.17.21; Wed, 28 Oct 2020 04:17:43 -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=axkVr+lk; 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 S1788739AbgJ0PAf (ORCPT + 99 others); Tue, 27 Oct 2020 11:00:35 -0400 Received: from mail.kernel.org ([198.145.29.99]:57728 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1782244AbgJ0O44 (ORCPT ); Tue, 27 Oct 2020 10:56:56 -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 33D4422284; Tue, 27 Oct 2020 14:56:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603810615; bh=JZO0FMmtG4vn/Ir8BKBtAao/jx/uemYfhrNZ6ukyQ5c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=axkVr+lkRyd0OdM4O/tqJKk6uCHCueFRN4hsrnCGXarjfMEIVNxxV41eYfSuhZcFP W+dfmDl9AVOVlqx8ppGgsKUufGGwI+3uB9gTDGwVYEsNNKLNjrexVWsOPObQZOsoYM DXuQncN3c22zz6CYzs2MxO6WDu0rDl6ZKfc2ALU4= 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.8 202/633] video: fbdev: sis: fix null ptr dereference Date: Tue, 27 Oct 2020 14:49:05 +0100 Message-Id: <20201027135532.161955285@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135522.655719020@linuxfoundation.org> References: <20201027135522.655719020@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