Received: by 2002:a05:7412:bc1a:b0:d7:7d3a:4fe2 with SMTP id ki26csp1262242rdb; Mon, 21 Aug 2023 02:16:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHAVa3B3ncUQwYR6pxii78pJGnCusIKGjlug11FljJKrc37GXPChVSK5nuySlcCf2/6htom X-Received: by 2002:a17:906:51c9:b0:99d:ef0e:e95e with SMTP id v9-20020a17090651c900b0099def0ee95emr4434199ejk.13.1692609405392; Mon, 21 Aug 2023 02:16:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692609405; cv=none; d=google.com; s=arc-20160816; b=Bcwbtl4uZekv+bk4FWhPv82AQGRhjZ5tS8FutNy4GY729WP9nMWGRP4UoOnIDcthDo SaEtkKBRU1ZyLFAFIC08ax6G4/kj9PEzMYbyTPpDV2DCpdy59T6TldM9u9zWdGzNPfz4 /4twIQKZmBhXdv7SrQuuagFvSgI/fiAIBeHDmT47ZD0183ZiYQvXkLSW1haFrpJ37A0H DxZ7wd8xJclqaorslXO0IUcqtvORaQ0QulIc4gg90ln54qErgXzTIWDYJrDVoCgweRmZ 17bT4nwPkkicAxwhjbBzoBz9BPXnGA4oxE4LPtLtp9CfKi/sZzqFYg2XN9fV4NRqju3B IzYA== 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 :message-id:date:subject:cc:to:from; bh=V+mOO6vaCfiF4Rq3WENlHyWpGD81ml87zBeTCZFWbGo=; fh=xf23x4RioSoc7hAB2IaS54MEa52EL7n5MHvw1n5S3r4=; b=QOnXJHDMJRZXozb0yF1KrUIq8flVMcUNhEdPNv+VjfTcaYuR8GctOaqMl+AZGq7NwK spOTXheRfV24Zq1TQjDZgwvGfnErNLkV+RAi6bMuhyDu7VMKGPvZ+5kvMKeN662bSmbO vNnp+Di31QPURRvGd9MOtjv70S+wo0SDHX2Uc0yUiWsjN8RaHn6ucDAUH3m9w7GlLsBh 7U+D5TpCCFGFUqKUAsEJ3OSS2qkSZnlwmCNz3fY6KMYHhwZN7pYAHl9NFvAVV7HeIPez tlW/8CPe8MEg8T1OhsrtgCADtf7Rmsotr2+n1MpYPgT6UdR25RNrOaRhirILN5UXE7K7 ZNpQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n9-20020a1709065e0900b00992d7428e55si5072145eju.922.2023.08.21.02.16.16; Mon, 21 Aug 2023 02:16:45 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230161AbjHUGWx (ORCPT + 99 others); Mon, 21 Aug 2023 02:22:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33226 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229954AbjHUGWw (ORCPT ); Mon, 21 Aug 2023 02:22:52 -0400 Received: from mail.nfschina.com (unknown [42.101.60.195]) by lindbergh.monkeyblade.net (Postfix) with SMTP id A16AA102; Sun, 20 Aug 2023 23:22:15 -0700 (PDT) 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 Cc: eich@suse.de, tiwai@suse.de, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Su Hui 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 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,RDNS_NONE, SPF_HELO_NONE,SPF_PASS autolearn=no 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 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); -- 2.30.2