Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp628972iog; Mon, 13 Jun 2022 09:27:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJymv5xyBpiL8oNZ7TIxJY6ZGq12Z+UccFiEGYf+UqoMkcHqL5e/cF+K3dnwZHoEiRvpBmMM X-Received: by 2002:a65:6786:0:b0:3fc:e1c0:7bbc with SMTP id e6-20020a656786000000b003fce1c07bbcmr370208pgr.65.1655137653108; Mon, 13 Jun 2022 09:27:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655137653; cv=none; d=google.com; s=arc-20160816; b=RXOhDqRTzN+a27JvOyFu2XkzP2wp4ZQLPDgZefaB2vdL/ljW7uTsB5RiLcPFnYXXRl 29kAKseEn/CyOw02LnJtVrjnQ3MZjQ/e72BdsZMBRaEsCX0Pv8bn2GJAym23Zsg59bhE vLwbZKGjFbLHJrJ0N1i/r/8xFQ7ydPJnmTXlEziJGt+dU5/RBhy83NgUb54Z0Nvc/Tnm 8j/k2ybYKJAykZ6I/v+kZmZICkHmt2rprak1lcuTxz6OsjLTIEZNUHHrZysnjvUy21V6 bgwDEZJh4sRZHsXg0nTVKVDpd9kiJW4WLLXMVkqq2S10LOx74ycuERt6/dlyzURaCN9F IpDQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=B+P215YOC95+w/7jSXA6aqcSghNv9icH2lZLWPx1l1Y=; b=vVwWRvUQTUDhtWgearyyeR/320XuoyzkVxSqYaj9PryvJovpzYCA19sQhkz2lUG97E 04U2gmu+nxZKzdQ92WxAjljGKvMCosBIIz+YsI62NnIxWXw/UQC7an5LchkiC8AShfjG 7HK+2EII5Q68ZYgDU3NpPl/02biGm4GdZZMDGkNviCsQaefmDoChU/PXfZUoJMKgCpnr PqslsnjXUT5BqbaGwQ1jKp0rRgcQaEaha0QgLM36zPpYk82Fh26tkzdrlxRh5XetqtId 8xiVEoGSt0MH8evu7t2LVyhzPvMST3eXfsOS4k0NRakpPeybSy1TflusIy4oz1JbMXi4 TqwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=TX5y2oss; 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=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e10-20020a170902cf4a00b001678a65d755si9611287plg.154.2022.06.13.09.27.11; Mon, 13 Jun 2022 09:27:33 -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=@linuxfoundation.org header.s=korg header.b=TX5y2oss; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345941AbiFMKgg (ORCPT + 99 others); Mon, 13 Jun 2022 06:36:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42078 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346939AbiFMKej (ORCPT ); Mon, 13 Jun 2022 06:34:39 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E44FB2709; Mon, 13 Jun 2022 03:22:32 -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 sin.source.kernel.org (Postfix) with ESMTPS id D7A4DCE0EEB; Mon, 13 Jun 2022 10:22:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E0931C34114; Mon, 13 Jun 2022 10:22:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1655115748; bh=kvByzdNQK2btTZ+fpFAvasfh10IP/7TU2FF2HCwqQdA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TX5y2osss+UgMqQXxVp938QSQNuslBwFTosBGROq2+cEsK2EfNBe1TCGcaS6czO9F S2tOABfQXGqws2vO1aSc/Hv1Eu9WIIa90QD9YZ+MBYPypbSrBPkPbjdCEU1i+5A0hH j6G44rbyp5Ddcw9keKP6K86C7aYcxe8lVcs6N088= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Luca Weiss , Stanimir Varbanov , Mauro Carvalho Chehab , Sasha Levin Subject: [PATCH 4.14 017/218] media: venus: hfi: avoid null dereference in deinit Date: Mon, 13 Jun 2022 12:07:55 +0200 Message-Id: <20220613094912.414041489@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220613094908.257446132@linuxfoundation.org> References: <20220613094908.257446132@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-8.3 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 ba29fd4d4984..7d1d3e64007c 100644 --- a/drivers/media/platform/qcom/venus/hfi.c +++ b/drivers/media/platform/qcom/venus/hfi.c @@ -117,6 +117,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