From patchwork Wed Apr 7 14:10:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin King X-Patchwork-Id: 417055 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 42938C433B4 for ; Wed, 7 Apr 2021 14:10:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2569761260 for ; Wed, 7 Apr 2021 14:10:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352785AbhDGOKV (ORCPT ); Wed, 7 Apr 2021 10:10:21 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:42993 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235710AbhDGOKS (ORCPT ); Wed, 7 Apr 2021 10:10:18 -0400 Received: from 1.general.cking.uk.vpn ([10.172.193.212] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1lU8se-00029E-Ox; Wed, 07 Apr 2021 14:10:04 +0000 From: Colin King To: Stanimir Varbanov , Andy Gross , Bjorn Andersson , Mauro Carvalho Chehab , Bryan O'Donoghue , Dikshita Agarwal , linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH][next] media: venus: hfi, pm, firmware: Fix dereference before null check on hdev Date: Wed, 7 Apr 2021 15:10:04 +0100 Message-Id: <20210407141004.495093-1-colin.king@canonical.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org From: Colin Ian King The pointer hdev is being dereferenced twice on the assignment of pointers cpu_cs_base and wrapper_base before hdev is being null checked. Fix the potential null pointer dereference issues by performing the null check of hdev before dereferencing it when assigning cpu_cs_base and wrapper_base. Addresses-Coverity: ("Dereference before null check") Fixes: ff2a7013b3e6 ("media: venus: hfi,pm,firmware: Convert to block relative addressing") Signed-off-by: Colin Ian King Reviewed-by: Muhammad Usama Anjum --- drivers/media/platform/qcom/venus/hfi_venus.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/qcom/venus/hfi_venus.c b/drivers/media/platform/qcom/venus/hfi_venus.c index cebb20cf371f..3eabb2646572 100644 --- a/drivers/media/platform/qcom/venus/hfi_venus.c +++ b/drivers/media/platform/qcom/venus/hfi_venus.c @@ -1094,12 +1094,14 @@ static irqreturn_t venus_isr(struct venus_core *core) { struct venus_hfi_device *hdev = to_hfi_priv(core); u32 status; - void __iomem *cpu_cs_base = hdev->core->cpu_cs_base; - void __iomem *wrapper_base = hdev->core->wrapper_base; + void __iomem *cpu_cs_base, *wrapper_base; if (!hdev) return IRQ_NONE; + cpu_cs_base = hdev->core->cpu_cs_base; + wrapper_base = hdev->core->wrapper_base; + status = readl(wrapper_base + WRAPPER_INTR_STATUS); if (IS_V6(core)) { if (status & WRAPPER_INTR_STATUS_A2H_MASK ||