Received: by 2002:a05:6358:111d:b0:dc:6189:e246 with SMTP id f29csp1106179rwi; Thu, 3 Nov 2022 00:44:28 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5TvKbeUIEzLmV9n/cT7tDFM+hEsDE38yJMuhR29RSz4TLJUkYlkyVrIY9bqqZVqVl/ArXj X-Received: by 2002:a17:902:e883:b0:187:27a7:c8a3 with SMTP id w3-20020a170902e88300b0018727a7c8a3mr17389047plg.32.1667461468771; Thu, 03 Nov 2022 00:44:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667461468; cv=none; d=google.com; s=arc-20160816; b=pTZOXNG2Dk0mPzlgRVxU0MpMywhpbAqp/MAQiIXP/CdBjPIifYlIjbYv/gbdV1qoK0 r3nr+zKybuQHLgsAbiC9toI+FQ/D4wwxOB5yYDZ6Tt/W+4iLOplssk704DtjJi+EyZuQ k+yrC1buxDV2HzQkc7FIxtLc5cnqfwBC8wg0gD66WW9SdgAX99RBK1JvRyBDXh1R8bJs 9YLdvHQ6ipVJUtT4u5FZTZrTtA6TAuAyCvTqit1tSb0ohyH4wUPcADa890GB4zaFGyh+ ITZE0fliJDlJvUjD7rizmO4btZtK4paHqf3tjiCU4mF3zpqnW4U6ukR219aBNh6qKSL/ 1nvA== 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:to:from; bh=P0qoUvkgnKG5G/JIaYK/rjy4QChBg3MB9ankLWZLsoY=; b=f+iAwVJIKNaOBfIDubdWgeNIKs5sOD1qRdRAvMtm1XAP8HBMsuCkCLeNlBa/65abhY oamQTprs6bMKBZVzUMw8mfaqseOw/uNN3yvAYad/hZFR2m8wF3ntE7R1TTZLoKb1CGc8 gM7l+967cNDWZXbGwpPAkuRDywh7lt6q6vtx8qhrxWjUL7y9Wsa6IB04tyvzz0fOPUne fj84xeQA5+mLt0VQw8FO2P7UKdOvjv3D5A02OMDIUS04EpAB4MBK47zylL8iM7oCn38z IjDAZIQPboIHDqFnWrZqTCsjG2dayBh6zxakzS9vm3ro94a66CiMCELoJY7kZ14RvP5N 9qCQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p5-20020a170902ebc500b001869b988da6si18277264plg.402.2022.11.03.00.44.15; Thu, 03 Nov 2022 00:44:28 -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; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230045AbiKCHMi (ORCPT + 97 others); Thu, 3 Nov 2022 03:12:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45594 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231336AbiKCHMS (ORCPT ); Thu, 3 Nov 2022 03:12:18 -0400 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0AAA21A043 for ; Thu, 3 Nov 2022 00:11:19 -0700 (PDT) Received: from dggpemm500022.china.huawei.com (unknown [172.30.72.55]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4N2w0L0HRJz15MKM; Thu, 3 Nov 2022 15:11:14 +0800 (CST) Received: from dggpemm500007.china.huawei.com (7.185.36.183) by dggpemm500022.china.huawei.com (7.185.36.162) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Thu, 3 Nov 2022 15:11:18 +0800 Received: from huawei.com (10.175.103.91) by dggpemm500007.china.huawei.com (7.185.36.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Thu, 3 Nov 2022 15:11:17 +0800 From: Yang Yingliang To: , , , , Subject: [PATCH 2/2] firmware: stratix10-svc: fix error handle while alloc/add device failed Date: Thu, 3 Nov 2022 15:09:51 +0800 Message-ID: <20221103070951.1496435-3-yangyingliang@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221103070951.1496435-1-yangyingliang@huawei.com> References: <20221103070951.1496435-1-yangyingliang@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.103.91] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpemm500007.china.huawei.com (7.185.36.183) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS 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 If add device "stratix10-rsu" failed in stratix10_svc_drv_probe(), the 'svc_fifo' and 'genpool' need be freed in the error path. If allocate or add device "intel-fcs" failed in stratix10_svc_drv_probe(), the device "stratix10-rsu" need be unregistered in the error path. Fixes: e6281c26674e ("firmware: stratix10-svc: Add support for FCS") Signed-off-by: Yang Yingliang --- drivers/firmware/stratix10-svc.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/firmware/stratix10-svc.c b/drivers/firmware/stratix10-svc.c index 1a5640b3ab42..bde1f543f529 100644 --- a/drivers/firmware/stratix10-svc.c +++ b/drivers/firmware/stratix10-svc.c @@ -1202,19 +1202,20 @@ static int stratix10_svc_drv_probe(struct platform_device *pdev) ret = platform_device_add(svc->stratix10_svc_rsu); if (ret) { platform_device_put(svc->stratix10_svc_rsu); - return ret; + goto err_free_kfifo; } svc->intel_svc_fcs = platform_device_alloc(INTEL_FCS, 1); if (!svc->intel_svc_fcs) { dev_err(dev, "failed to allocate %s device\n", INTEL_FCS); - return -ENOMEM; + ret = -ENOMEM; + goto err_unregister_dev; } ret = platform_device_add(svc->intel_svc_fcs); if (ret) { platform_device_put(svc->intel_svc_fcs); - return ret; + goto err_unregister_dev; } dev_set_drvdata(dev, svc); @@ -1223,6 +1224,8 @@ static int stratix10_svc_drv_probe(struct platform_device *pdev) return 0; +err_unregister_dev: + platform_device_unregister(svc->stratix10_svc_rsu); err_free_kfifo: kfifo_free(&controller->svc_fifo); err_destroy_pool: -- 2.25.1