From patchwork Mon Aug 21 06:22:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Su Hui X-Patchwork-Id: 13359184 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8272EEE49A0 for ; Mon, 21 Aug 2023 06:22:15 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DAE0810E1D9; Mon, 21 Aug 2023 06:22:14 +0000 (UTC) Received: from mail.nfschina.com (unknown [42.101.60.195]) by gabe.freedesktop.org (Postfix) with SMTP id 697DE10E1D9 for ; Mon, 21 Aug 2023 06:22:10 +0000 (UTC) Received: from localhost.localdomain (unknown [180.167.10.98]) by mail.nfschina.com (Maildata Gateway V2.8.8) with ESMTPA id 7DC1B6061F466; Mon, 21 Aug 2023 14:22:06 +0800 (CST) X-MD-Sfrom: suhui@nfschina.com X-MD-SrcIP: 180.167.10.98 From: Su Hui To: airlied@redhat.com, tzimmermann@suse.de, airlied@gmail.com, daniel@ffwll.ch Subject: [PATCH] drm/ast: Avoid possible NULL dereference Date: Mon, 21 Aug 2023 14:22:00 +0800 Message-Id: <20230821062159.198691-1-suhui@nfschina.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: eich@suse.de, Su Hui , kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" smatch error: drivers/gpu/drm/ast/ast_dp501.c:227 ast_launch_m68k() error: we previously assumed 'ast->dp501_fw' could be null (see line 223) when "!ast->dp501_fw" and "ast_load_dp501_microcode(dev) >= 0" is true, there will be a NULL dereference of 'ast->dp501_fw'. Fixes: 12f8030e05c6 ("drm/ast: Actually load DP501 firmware when required") Signed-off-by: Su Hui --- drivers/gpu/drm/ast/ast_dp501.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/ast/ast_dp501.c b/drivers/gpu/drm/ast/ast_dp501.c index 1bc35a992369..d9f3a0786a6f 100644 --- a/drivers/gpu/drm/ast/ast_dp501.c +++ b/drivers/gpu/drm/ast/ast_dp501.c @@ -224,8 +224,10 @@ static bool ast_launch_m68k(struct drm_device *dev) ast_load_dp501_microcode(dev) < 0) return false; - fw_addr = (u8 *)ast->dp501_fw->data; - len = ast->dp501_fw->size; + if (ast->dp501_fw) { + fw_addr = (u8 *)ast->dp501_fw->data; + len = ast->dp501_fw->size; + } } /* Get BootAddress */ ast_moutdwm(ast, 0x1e6e2000, 0x1688a8a8);