Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp3888302rwi; Sat, 22 Oct 2022 01:36:11 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7t/LTSWEdlFzrenmAvCSPeQ8ZzFNAzMxwPs863HTd7yh3gNrwFRzA81IgZEuwCPS0kWUfo X-Received: by 2002:a05:6a02:20c:b0:461:74e5:ce9f with SMTP id bh12-20020a056a02020c00b0046174e5ce9fmr19863512pgb.294.1666427771643; Sat, 22 Oct 2022 01:36:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666427771; cv=none; d=google.com; s=arc-20160816; b=GRJcuCp8KlojW1ov0Nv5TBB7usNznrgPa+7c0u/+oLpeLLl2asr3YAvlFqimTi2I+Q e63h/k8SmqGbTuyy3Jz6QAfNCwK2UTsNrEu3o+2MIpS315NUvOnVASjRvJ8bdhebuf/e +pPoZ+Bg6xJtfBlDCwB0a1sqUBpXigfqp2so7jwLMhn3unvQIaXlJUFZ55NjDhYfUU01 gRu4OOdFhVbcWqxDn/j/9r6bzw0CbUPruFV4ffuOJd5bOXsumaof4+DPBGzyRkIZSa28 SWIBkcDFVZsQD6gd9hBS/CSynUq+c/1agP1wHjg70o9MqLEh7PLfk76c50YmtDZhFxMC QJ0w== 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 Return-Path: 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.35.55; Sat, 22 Oct 2022 01:36:11 -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 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 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; -- 2.35.1