From patchwork Sat Oct 22 07:26:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 7522 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp1105166wrr; Sat, 22 Oct 2022 01:34:16 -0700 (PDT) X-Google-Smtp-Source: AMsMyM57yYJ+lX+ViAVKW7+sOim49GJV8eIue8uxbhBSQsi/XsPM+yy7lvaoVvjus4tbrj9j6fXq X-Received: by 2002:a63:1145:0:b0:46a:e00c:579c with SMTP id 5-20020a631145000000b0046ae00c579cmr20040838pgr.279.1666427656616; Sat, 22 Oct 2022 01:34:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666427656; cv=none; d=google.com; s=arc-20160816; b=XphGf/NBTRAreEXLMPEa0rEOSy6K3rSS6cTN/5F+xP5GKYGM5BJEv7tyvMPaEj78+g FmfMcbnCe4BhPIloERSROJrPRnRaD/RfezrSJZav+q4soqOZwH8ZJqZEUAUtT7/VNjfC hAw9chTx5JrCPIUkIcXUAkwRQF6XHSTI2s9aKDlm9FnRRQpXPCgvABS+zf8DBNzOxgzL zB3WZYxQzI5sreZwLSF/0/lIANklS3PuH0xXR+xQJAn2O/7ORAn2f1jUVED0LWoeKS8A M03a7cnPeuMMzsYRyqyQenVEU7OeWIaWXZqtt+Z7rgxXd1ardmhfHlBT86onsomLBXhp n4jg== 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=hlHXTeLk6Vus863ESYLLvMsfIytHocqsYinwuBwvjGE=; b=FKRm8m3RP35FZAXRQoJY2MIfto3UTvejNgGNIBUZM8KmsGSXn5yKYewpSprWPcYJnc I8AxInLrSSOjGGuMGTHilG47z0rkj+d6PrB/CMXcF07UHkPszOPSQ/Lzv7jWcje9S2ig WLt02Z679yC4kTgrmjLVyRnM3QfiCOeM2/WWDc4cEDEuDIUEgDcZodJkYWwu6OVWj9RD XbU95ctOTai/+/z00onbFTCP16DQabP4/oyhIm0mBLh65j3nYpLwmG4xYv4DLp9OVcqN IPuPbEWlLAc/rRZQUsE46Ymf91WHlGV69rt1Lrbr2b91umPsa2n9BKaNZfYK24G8sDjv VYsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=PCbbhWt7; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a7-20020a637f07000000b0043949ac7077si28242946pgd.418.2022.10.22.01.33.52; Sat, 22 Oct 2022 01:34:16 -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=PCbbhWt7; 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 S233754AbiJVIVG (ORCPT + 99 others); Sat, 22 Oct 2022 04:21:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54234 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233795AbiJVITo (ORCPT ); Sat, 22 Oct 2022 04:19:44 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E15D0D6BB4; Sat, 22 Oct 2022 00:58: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 dfw.source.kernel.org (Postfix) with ESMTPS id 7486160B91; Sat, 22 Oct 2022 07:56:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6B239C433C1; Sat, 22 Oct 2022 07:56:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666425392; bh=1Y7qpSB/p47Zdgo29zn1EKjizf5xN3DqjUZFK+QYqKQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PCbbhWt7zb9TKPWUQdTV0oZZVYa/GYwkhS3E/qExBJXXo7n1rgvhjhH4Ww01msjdv nAU59SyHRPj51rG2WT88Dc+Tq4onCKixmwsKkIODzqFoDA4zIY9XBw+4ztl+L9231E 8m2wE0vuftUXxpY3RdGiHebnJTYKawYgwB1ke+Rc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lin Yujun , Stephen Boyd , Sasha Levin Subject: [PATCH 5.19 485/717] clk: imx: scu: fix memleak on platform_device_add() fails Date: Sat, 22 Oct 2022 09:26:04 +0200 Message-Id: <20221022072519.828988984@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221022072415.034382448@linuxfoundation.org> References: <20221022072415.034382448@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.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 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?1747376046393926123?= X-GMAIL-MSGID: =?utf-8?q?1747376046393926123?= From: Lin Yujun [ Upstream commit 855ae87a2073ebf1b395e020de54fdf9ce7d166f ] No error handling is performed when platform_device_add() fails. Add error processing before return, and modified the return value. Fixes: 77d8f3068c63 ("clk: imx: scu: add two cells binding support") Signed-off-by: Lin Yujun Link: https://lore.kernel.org/r/20220914033206.98046-1-linyujun809@huawei.com Signed-off-by: Stephen Boyd Signed-off-by: Sasha Levin --- drivers/clk/imx/clk-scu.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/clk/imx/clk-scu.c b/drivers/clk/imx/clk-scu.c index c56e406138db..1e6870f3671f 100644 --- a/drivers/clk/imx/clk-scu.c +++ b/drivers/clk/imx/clk-scu.c @@ -695,7 +695,11 @@ struct clk_hw *imx_clk_scu_alloc_dev(const char *name, pr_warn("%s: failed to attached the power domain %d\n", name, ret); - platform_device_add(pdev); + ret = platform_device_add(pdev); + if (ret) { + platform_device_put(pdev); + return ERR_PTR(ret); + } /* For API backwards compatiblilty, simply return NULL for success */ return NULL;