Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp1156300rwb; Thu, 6 Oct 2022 09:07:25 -0700 (PDT) X-Google-Smtp-Source: AMsMyM69DI9QMT276JfXhjSYB1yCiQ7o0bilmwNDopreQYgO7dG7fIVyXoj5IQSOqr+1Ub1O0at3 X-Received: by 2002:a17:907:2cd0:b0:78d:a09:55f7 with SMTP id hg16-20020a1709072cd000b0078d0a0955f7mr434851ejc.541.1665072445346; Thu, 06 Oct 2022 09:07:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665072445; cv=none; d=google.com; s=arc-20160816; b=F5Q6SfOb1zqGGDmU7Y8c+qJIdCGmkBqes1+xUbV+cSF2Ln/0CGd69keuea/g6mDR7L TqLVx6XaQkTbCccR9xIUte0zUOwngbU0OqQUKHGFJWOTVlra7SBkR19CS7HKGN1e/Q4W pITvnY1wlEoaQ1pRgXILyZo8ol68nf/GX3MjobZcs6rQp1oEW72j1zO66q+sH7nAMeg/ isezkhg36ukwPUfV0lBIZaiyHRALWysmWOXOGECpVhDfxm+svLAxfj6WKMADwMvIXW90 xjdXoxYL/1R8uKQEOH5ZST/C2RcsRDlyiaIjiBd4JITCFZPKBN8/EsAdw3Tv47K7qdeV FuFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from :dkim-signature; bh=oyQcrxZYCAvggulovd4FRHdXOU2WjZQVKRd7NG1+zj8=; b=OL1gkdnQ2+sGf7NsNer/jn+PDvFpVXILQ7SSRIug4+sJk9L6EqSX7augnx9Hy2K2Tl 8JaRkGQedbWIDVqjVogvP+eciIuMe/yCCGmP4nGTVUtr/H8vgfZny4jyQbRbBfvLk1bH Ed3BOCQemPbhgLP5AuTzgedrMQIaa7CpsO4T3jTNyKpk5Pj+IH6ap6mjHfzlxzC0S4w2 42En3y98BqaWBwhiiKDGMRqC0fO0TUo2b228GPoJ47kjpTHX1rmNTkWbDCONpa9tX/SX X/R4W7GS56mlPvUufKDRaLEGRNVBoFXOWxNwD00ac3Bv+RavnGvNbt8Co9qX9PGm0J+5 4H0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=p8N6h9I1; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s1-20020a17090699c100b0073d751c96adsi12820390ejn.1000.2022.10.06.09.06.52; Thu, 06 Oct 2022 09:07:25 -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=p8N6h9I1; 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 S230227AbiJFPQL (ORCPT + 99 others); Thu, 6 Oct 2022 11:16:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50726 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229527AbiJFPQJ (ORCPT ); Thu, 6 Oct 2022 11:16:09 -0400 Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 92180A59A6; Thu, 6 Oct 2022 08:16:02 -0700 (PDT) X-UUID: dc14bd85e839499fba43ab84e6888523-20221006 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:MIME-Version:Message-ID:Date:Subject:CC:To:From; bh=oyQcrxZYCAvggulovd4FRHdXOU2WjZQVKRd7NG1+zj8=; b=p8N6h9I1xEIzT+RLRfn+ixVQ/U+pJQIb1WaPlfiZNrSTmi+u5GgLCpMmeRRkcYbHOJ8TCORE0js6QNmZ1IRyfnXOJhVMJQNt+ej4cSSJdxWC4As3hUqzAHWiqqH5bj/ivSm4f5K7o6E6l2pK2vb+ACNzn8LAXN9Ew4B0Op7LNig=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.11,REQID:7eb20aea-da04-41e6-bc0b-4d53c687f712,IP:0,U RL:0,TC:0,Content:-25,EDM:0,RT:0,SF:100,FILE:0,BULK:0,RULE:Release_Ham,ACT ION:release,TS:75 X-CID-INFO: VERSION:1.1.11,REQID:7eb20aea-da04-41e6-bc0b-4d53c687f712,IP:0,URL :0,TC:0,Content:-25,EDM:0,RT:0,SF:100,FILE:0,BULK:0,RULE:Spam_GS981B3D,ACT ION:quarantine,TS:75 X-CID-META: VersionHash:39a5ff1,CLOUDID:9de575fe-ee8c-4ff7-afe9-644435e96625,B ulkID:221006231557JDPH4WSB,BulkQuantity:0,Recheck:0,SF:38|28|17|19|48|823| 824,TC:nil,Content:0,EDM:-3,IP:nil,URL:0,File:nil,Bulk:nil,QS:nil,BEC:nil, COL:0 X-UUID: dc14bd85e839499fba43ab84e6888523-20221006 Received: from mtkmbs10n1.mediatek.inc [(172.21.101.34)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 855305414; Thu, 06 Oct 2022 23:15:56 +0800 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by mtkmbs11n2.mediatek.inc (172.21.101.187) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.792.15; Thu, 6 Oct 2022 23:15:55 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkmbs11n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.792.15 via Frontend Transport; Thu, 6 Oct 2022 23:15:55 +0800 From: Moudy Ho To: Mauro Carvalho Chehab , Matthias Brugger , Hans Verkuil CC: Chun-Kuang Hu , , , , , Moudy Ho Subject: [PATCH v1] media: platform: mtk-mdp3: fix error handling in mdp_probe() Date: Thu, 6 Oct 2022 23:15:53 +0800 Message-ID: <20221006151553.28083-1-moudy.ho@mediatek.com> X-Mailer: git-send-email 2.18.0 MIME-Version: 1.0 Content-Type: text/plain X-MTK: N X-Spam-Status: No, score=-1.6 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS,UNPARSEABLE_RELAY, URIBL_CSS autolearn=no 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 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 --- .../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; } -- 2.18.0