From patchwork Thu Oct 20 07:18:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?TW91ZHkgSG8gKOS9leWul+WOnyk=?= X-Patchwork-Id: 5997 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp110841wrs; Thu, 20 Oct 2022 00:20:34 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7KOtXLhK7S4Q6mZub+RbcGVr10nzpZnPgskyOYGgURuTqsVvoWK8U3CBa+RjeLmH3SJFv4 X-Received: by 2002:a17:906:1ec5:b0:78d:b3d1:183b with SMTP id m5-20020a1709061ec500b0078db3d1183bmr9748212ejj.709.1666250434554; Thu, 20 Oct 2022 00:20:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666250434; cv=none; d=google.com; s=arc-20160816; b=r7xsdUkztzuTxiloDeuvZa9ZThxtztEzEM2QzAdRgCzsTgiIemP/DqU6QKgt+Q1NM5 pHj4TVyD7au4PeB19nPpLjMN49VJdyeFiIHZ2E5rYqedy0s8PE/7bXe06hTpCjauUzwe Ej6g5PT1ShwBKKPiN2ItSNdwhLBphSlDUWwVqR622eRIypuEfgnYM0HWOSLDXyZ6Wfi+ 5IuDsY4aJl5JxAFnrfxGhUyBsTudD+HWeyv+P6I5UwpvAi6VhxHwMOwP68M9cp3r0W8D Hzy1/+PHLjQGEWBopP1WeCylQEy7ySLO4z3YDhAJIJfDZ+iErVyx9cZmAUtQ+CBOn87v CgOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=oyQcrxZYCAvggulovd4FRHdXOU2WjZQVKRd7NG1+zj8=; b=XXOr3lojI20TENfAj2mP7YgFp3Q2DeYej5Qz/M9M4AnKZSlP8VCNCmC8TlWHjuLG65 pIgHeONersYneRd/RBPj6IreqyppSgse0ZIzaQN9TTWUhnrNpnDgN0XPtMAboIYqtpIF LLUzdr9t+m5xrVVZhHeyqNd1ciHxmpMJvr7z9Al3YpDQjzPNMbUT9AHerzlQasMflaPv VllZmqlddt8ubF90cR93NBJLB+9P+u4P0UjjXVcCfJAttQ3FbqqFL1zC6QN8hzt5e/7p qvV3f2rXboGg4Nwyde6hZQYc2e1UZRCIvOeFqYdFpCD06F1hndmR2oaFxjfZmNVBc1uF x+4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=ByhDzTpY; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i3-20020aa7dd03000000b00456c837e3d0si14227999edv.77.2022.10.20.00.20.09; Thu, 20 Oct 2022 00:20:34 -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=@mediatek.com header.s=dk header.b=ByhDzTpY; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230337AbiJTHSy (ORCPT + 99 others); Thu, 20 Oct 2022 03:18:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44524 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230294AbiJTHSd (ORCPT ); Thu, 20 Oct 2022 03:18:33 -0400 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 02CD216E2A0; Thu, 20 Oct 2022 00:18:16 -0700 (PDT) X-UUID: 30801a809907421980614ac785b065f5-20221020 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=oyQcrxZYCAvggulovd4FRHdXOU2WjZQVKRd7NG1+zj8=; b=ByhDzTpYCFzjWm1qSQJjbRkLtm2f8JTZfj4d6d1o8DPc4UaTRpqRfpVDCYZYSgHyLbkMLSRX9uxPcGd70Q0iTA8nkVUlTF37BsC2cjuy4IUXTxDNdPZGyE9Ap9RF7J4/KY1qrg5Oh1W7Y5qoHnfVWWeL/u6hxwq0q0IYwxn3Fyc=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.12,REQID:e6256586-8665-42f6-9e5d-9e85b35cc3bd,IP:0,U RL:0,TC:0,Content:-25,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTIO N:release,TS:-25 X-CID-META: VersionHash:62cd327,CLOUDID:3a4fe0ee-314c-4293-acb8-ca4299dd021f,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:-3,IP:nil,U RL:0,File:nil,Bulk:nil,QS:nil,BEC:nil,COL:0 X-UUID: 30801a809907421980614ac785b065f5-20221020 Received: from mtkmbs11n1.mediatek.inc [(172.21.101.185)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1287693578; Thu, 20 Oct 2022 15:18:03 +0800 Received: from mtkmbs13n2.mediatek.inc (172.21.101.108) by mtkmbs10n2.mediatek.inc (172.21.101.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.792.3; Thu, 20 Oct 2022 15:18:02 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkmbs13n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.792.15 via Frontend Transport; Thu, 20 Oct 2022 15:18:02 +0800 From: Moudy Ho To: Mauro Carvalho Chehab , Matthias Brugger , Hans Verkuil CC: Chun-Kuang Hu , , , , , Moudy Ho Subject: [PATCH v3 3/3] media: platform: mtk-mdp3: fix error handling in mdp_probe() Date: Thu, 20 Oct 2022 15:18:00 +0800 Message-ID: <20221020071800.20487-4-moudy.ho@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20221020071800.20487-1-moudy.ho@mediatek.com> References: <20221020071800.20487-1-moudy.ho@mediatek.com> MIME-Version: 1.0 X-MTK: N X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, SPF_PASS,UNPARSEABLE_RELAY,URIBL_BLOCKED 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747190215297215632?= X-GMAIL-MSGID: =?utf-8?q?1747190215297215632?= Adjust label "err_return" order to avoid double freeing, and add two labels for easy traceability. Fixes: 61890ccaefaf ("media: platform: mtk-mdp3: add MediaTek MDP3 driver") Signed-off-by: Moudy Ho Reviewed-by: AngeloGioacchino Del Regno --- .../media/platform/mediatek/mdp3/mtk-mdp3-core.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.c b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.c index c413e59d4286..2d1f6ae9f080 100644 --- a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.c +++ b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.c @@ -196,27 +196,27 @@ static int mdp_probe(struct platform_device *pdev) mm_pdev = __get_pdev_by_id(pdev, MDP_INFRA_MMSYS); if (!mm_pdev) { ret = -ENODEV; - goto err_return; + goto err_destroy_device; } mdp->mdp_mmsys = &mm_pdev->dev; mm_pdev = __get_pdev_by_id(pdev, MDP_INFRA_MUTEX); if (WARN_ON(!mm_pdev)) { ret = -ENODEV; - goto err_return; + goto err_destroy_device; } for (i = 0; i < MDP_PIPE_MAX; i++) { mdp->mdp_mutex[i] = mtk_mutex_get(&mm_pdev->dev); if (!mdp->mdp_mutex[i]) { ret = -ENODEV; - goto err_return; + goto err_free_mutex; } } ret = mdp_comp_config(mdp); if (ret) { dev_err(dev, "Failed to config mdp components\n"); - goto err_return; + goto err_free_mutex; } mdp->job_wq = alloc_workqueue(MDP_MODULE_NAME, WQ_FREEZABLE, 0); @@ -287,11 +287,12 @@ static int mdp_probe(struct platform_device *pdev) destroy_workqueue(mdp->job_wq); err_deinit_comp: mdp_comp_destroy(mdp); -err_return: +err_free_mutex: for (i = 0; i < MDP_PIPE_MAX; i++) - if (mdp) - mtk_mutex_put(mdp->mdp_mutex[i]); + mtk_mutex_put(mdp->mdp_mutex[i]); +err_destroy_device: kfree(mdp); +err_return: dev_dbg(dev, "Errno %d\n", ret); return ret; }