Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp4547140ioo; Tue, 31 May 2022 06:51:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwWGeTAEl1sL60LGmTk1SEHRYbgz66OYRmjyBzskPHAHZitu4FVwiYYiSAHQmKZB/w3huJ7 X-Received: by 2002:a17:906:3e12:b0:704:6e14:9726 with SMTP id k18-20020a1709063e1200b007046e149726mr1033753eji.457.1654005119333; Tue, 31 May 2022 06:51:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654005119; cv=none; d=google.com; s=arc-20160816; b=Ff08U4lLS47vX5CAkBkQz3Ae7qY7PZHp+EWokqP3iUYLVTqHqi5VyPpKWScZZN0eEL nekT2hWSPd6fiRmdbbLYzzaZ8/vIBJrqAJW4FuTfcBXjyd68nw0Du4XVYTRKoiJ7QwO2 Dzmvn9eDsR+Uags4Bsmh1ej/MefVVnXxEfVpDjj98e/Lm4Brl3OU2DvskKRojOrN69ZU SBqmFx08XuD5cD7CJXdWZJ8A7gALs6w2Foe6hYx+QLdbP+YqAD2M3/qPoSIJ9WWvn1QN 7eUshsQy06Y0cj8xHrGHO3sTl4Q5YT37S/LiD2dHaXIVfTbn/swpiwQiJkAyfl57xgBS PlEw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=LYMedo3DRMeRF5+88UV+HesgHvcqJgQBXs+g9XlaFvw=; b=T0LdoXsiwpVDA89eOa0E3P+VKktbGRyzcwgssjKUuw/VEt/OFpDCUdss5utmctxzQE FqoE9Je8yohH47/D03tOK4Rp0ASJ6gpFhLcy4N2dOZgJ5RLVJ5LihHwbq8M1PxLzzTLH Ml3QOmXAS2iZdNZQnHX5MICfc+jJqOoV4FfYxF+5l+cBSog5FSa/0xDv/QcFg+uaAp67 42rdXYQAEKLsrhoopal9YB8IY1W7z0+WHxq3m+dLr73Rp5rebtkJk33Fl/h8xSM5BCtb 4ex0heACRJINGVenFFMKC2ml6oBITSho4J/L3rtM7325TLlB7YeM4ZKawzzS1frs5Jc3 Crog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="BzAFH/Ds"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hr16-20020a1709073f9000b006fe9d22875esi16945516ejc.761.2022.05.31.06.51.32; Tue, 31 May 2022 06:51:59 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="BzAFH/Ds"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241424AbiE3OaZ (ORCPT + 99 others); Mon, 30 May 2022 10:30:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40382 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241542AbiE3ORl (ORCPT ); Mon, 30 May 2022 10:17:41 -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 916DE55205; Mon, 30 May 2022 06:47:41 -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 A660360DDE; Mon, 30 May 2022 13:47:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E073CC36AED; Mon, 30 May 2022 13:47:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1653918460; bh=w45OzuGuLmtj9sEylkHgxYIfZXvDGqEsrxVIkJCabSU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BzAFH/DsZYx0earz7+CMjU3uSb2I9Yi7Kbds74T0dMAQ6s9Wui2QXtgc3d+Li5FZu 7uf+QrSbg1zfIR47LKD0r306csXYQSjXfklrWxWcPHdVKQLZSVwVum5uPFLrdOxLQ5 x3jKX64RYsHAxu5DWaHjUJkYmeV0LUQRG20VDoJ/mtD6IaYLe23mqocXPqEr52Rvt8 UEyI6j76hzTNLiaVUHBAz32OcgWBZGiZHU5DkAaWi4y4hQfHHVUu+EPM+zw7VG+Ql+ Fcunu3khKHTd0AJpNSAQp2NkQmmEjKGT7z/h6Fq9PnHqNS7DJm0B8iMy7+enZvTJnZ pXdsyeCinhvyQ== 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.4 15/55] media: venus: hfi: avoid null dereference in deinit Date: Mon, 30 May 2022 09:46:21 -0400 Message-Id: <20220530134701.1935933-15-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220530134701.1935933-1-sashal@kernel.org> References: <20220530134701.1935933-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 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 3d8b1284d1f3..68964a80fe61 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