From patchwork Tue Nov 29 16:36:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dinh Nguyen X-Patchwork-Id: 27338 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp448763wrr; Tue, 29 Nov 2022 08:44:58 -0800 (PST) X-Google-Smtp-Source: AA0mqf7sCTALd37/KILRpZ14BrhsoHK1UPzRZOkRvLZesnQGdQHaCb9X/BEAUf5OE0u8hQr4523/ X-Received: by 2002:a17:906:ad8a:b0:7bc:e5ac:c96f with SMTP id la10-20020a170906ad8a00b007bce5acc96fmr18390047ejb.433.1669740298708; Tue, 29 Nov 2022 08:44:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669740298; cv=none; d=google.com; s=arc-20160816; b=xplY0gd5KrlvA02hSlN4mdx+Ghr48RvgPmA3gSoIg8eol1G9pBrCL/JKT/hOcC9h8p 3swZmRD+lPkq6dzwDkK0WjUI9u9/yvmM3YeHQFHfnPnq4ZPVOoT2bz5ESHippJe4FAl6 3jdbcmrLjW7aym7SgA4pj81+U5fYxULf5IBtT+VjEyEBGnMjgoEViMfePjXWKko7yMl9 sM5y7qKOTVtyfGA1XHUhrlQFaBB29kUPOnA+qHExMcXFUeeJJW7thZToOFOtHGLfRTqB bFWmVx0Nmt7znkF8HQeDNPsaP5k3SBd/qT/b/E8gTl7FZEU2JTLocjOWkS0a5IJlpHMW EH6w== 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=JO3gMxnk2WXUX9phbSgazaC0HPtjVBCiPOT8U9QeeCk=; b=FXuIB73OEU3OvEXSBKrqWY8arJ9LCJiXHFVlMRLS+GDtUvZ8BkhwxyNxzBzZ3T11BO QagKFI6yQVB7+9wx+EHenLul1MtboD+fALjEHzvGSE6hmvzWY53aU+93unCdULL81XkL cNNYImhEMB6yBne2ijTGW/FSpge+ZPFFHFsEPiwphb8m1HbKjXFJeFJ2/RgjTlaT1KAH 7KD+gdU/zNCTAqjI5B8bnLWZYJTdwfFUWbAGaYXNyqEohuW8nxyr+eCwbm8fw+Y1VtDx wCpP3ZxHanrirVwo29xLdZ/BHqhFBWrrOhG4MU/fkKQ4sCyQ7KxL4peGKmNp5EA3q+xN 9RUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=rx5zoWiT; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hd43-20020a17090796ab00b007721f88d3e0si13058228ejc.554.2022.11.29.08.44.35; Tue, 29 Nov 2022 08:44:58 -0800 (PST) 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=rx5zoWiT; 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 S235714AbiK2QgZ (ORCPT + 99 others); Tue, 29 Nov 2022 11:36:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33824 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235992AbiK2QgQ (ORCPT ); Tue, 29 Nov 2022 11:36:16 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 47CA55DB94 for ; Tue, 29 Nov 2022 08:36:15 -0800 (PST) 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 ams.source.kernel.org (Postfix) with ESMTPS id 00F16B8167C for ; Tue, 29 Nov 2022 16:36:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4A3F6C433D7; Tue, 29 Nov 2022 16:36:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669739772; bh=FJV1S73SW2NjSjVVRTEYHknyVYkTqRLDNdBjhJdxKd0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rx5zoWiT7UjBAwvJ9mL7z2rhlretxV8nmTj3yjPW2bu0a+xL04WmDHozhVFIB/3CE der71B/JGgA8M2n6BpCU5Z+ifuilKwycZDKkty6n20UBYVKtI3ov/woqytf0aQt9zl UQae/4qKOSl5abNpA2QhUQwubilNf3NLz564YrnRPJsble1If4GSN9AvqCtUlztvVC oiwk+R0cRclHXK0XnoZmtyCfgp2kvRDy6tW9l2p7bLltc6R9U542kML7D83s2zwwcD QR2xlDJIfVYffBX5J7KPFbnicHppWTia5U8gVwL1kIy4yqsKHmNzgdJzhQWcwIdcWd iCcacvQVdRKpA== From: Dinh Nguyen To: gregkh@linuxfoundation.org Cc: dinguyen@kernel.org, linux-kernel@vger.kernel.org, Yang Yingliang Subject: [PATCH 2/2] firmware: stratix10-svc: fix error handle while alloc/add device failed Date: Tue, 29 Nov 2022 10:36:02 -0600 Message-Id: <20221129163602.462369-2-dinguyen@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221129163602.462369-1-dinguyen@kernel.org> References: <20221129163602.462369-1-dinguyen@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 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 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?1750849603490945107?= X-GMAIL-MSGID: =?utf-8?q?1750849603490945107?= From: Yang Yingliang 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 Signed-off-by: Dinh Nguyen --- 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: