From mboxrd@z Thu Jan 1 00:00:00 1970 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 61A66C43217 for ; Mon, 30 May 2022 13:52:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235238AbiE3NwR (ORCPT ); Mon, 30 May 2022 09:52:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41276 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238792AbiE3Np5 (ORCPT ); Mon, 30 May 2022 09:45:57 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6056AA0D09; Mon, 30 May 2022 06:33:36 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 006A660E9B; Mon, 30 May 2022 13:33:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2E876C3411A; Mon, 30 May 2022 13:33:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1653917611; bh=1rMP8kZatU4ASe70FEHQC3m9PZKnZRDIpdNd/40kEeE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TUmV3j/FDdfWx6IJMRliOyqi8DSAM7Xiv/9rz7cvrbZv5YF/IJy/z7CcZQhQoEcKq xwVkapDxp3S5kqFtBurG2BhRpcv3dPx5TXnwSr8YKs+/QC4USWheTxUGzIIeaiXM7n 7W/fSg6+1x5EVSW4wG5BqaS8JZMJmjAzknYToCJvu63ubUWZPFXorEebv0QvamNUS0 pkeuqerQkbqUA9By3E2Dn9/X7ksA2d1BVuW5VZuEwGGUiZrnfq3GmCV+FRT5JGSjpa fJq2t97rBvLMJhPm2IYi89kIHimczfUj9JwCByTzpOV1uP4SHFhhZJJFWtfzb73Pmp 9PHT6sKqjmn+A== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Luca Weiss , Stanimir Varbanov , Mauro Carvalho Chehab , Sasha Levin , agross@kernel.org, bjorn.andersson@linaro.org, linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: [PATCH AUTOSEL 5.17 040/135] media: venus: hfi: avoid null dereference in deinit Date: Mon, 30 May 2022 09:29:58 -0400 Message-Id: <20220530133133.1931716-40-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220530133133.1931716-1-sashal@kernel.org> References: <20220530133133.1931716-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Luca Weiss [ Upstream commit 86594f6af867b5165d2ba7b5a71fae3a5961e56c ] If venus_probe fails at pm_runtime_put_sync the error handling first calls hfi_destroy and afterwards hfi_core_deinit. As hfi_destroy sets core->ops to NULL, hfi_core_deinit cannot call the core_deinit function anymore. Avoid this null pointer derefence by skipping the call when necessary. Signed-off-by: Luca Weiss Signed-off-by: Stanimir Varbanov Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/media/platform/qcom/venus/hfi.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/media/platform/qcom/venus/hfi.c b/drivers/media/platform/qcom/venus/hfi.c index 4e2151fb47f0..1968f09ad177 100644 --- a/drivers/media/platform/qcom/venus/hfi.c +++ b/drivers/media/platform/qcom/venus/hfi.c @@ -104,6 +104,9 @@ int hfi_core_deinit(struct venus_core *core, bool blocking) mutex_lock(&core->lock); } + if (!core->ops) + goto unlock; + ret = core->ops->core_deinit(core); if (!ret) -- 2.35.1