Received: by 2002:a05:622a:251a:b0:39a:b4a2:e86 with SMTP id cm26csp328784qtb; Wed, 19 Oct 2022 03:06:50 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5uWCuODxB64t3lmqgl/AGdyagGb5uqzaNDbcbVvcKOkutrSkSBkPF7u2gZ+AySQsidPnLL X-Received: by 2002:a65:6e0e:0:b0:434:59e0:27d3 with SMTP id bd14-20020a656e0e000000b0043459e027d3mr6352869pgb.185.1666174009995; Wed, 19 Oct 2022 03:06:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666174009; cv=none; d=google.com; s=arc-20160816; b=IgswYPraPsEANDS1Tn49l2BKfotHYVT8Z74Jb6I4QkErkJhZqL1TI2gX8KgrR341FY tEFKmG6uVmjjdsqZBnRz2EmqxMI10HJf71FqzMVmyYkQN+L0EZH+DCIPepdTJ//CuMOY m1Z3ndD8fofuHs0IHljCNEzeyoDjzSkiYAbAwXa/B71l7BqhyiLC1jskzHMf/qXXxnI1 MVQ+RlifS1qalfTtUS5dEJ2kQI/1Rd2IBEs9akeUXi2hcMTsVuRuGi/KZjjTwscC/qXF 7kycZSOvTJKMlDe1sroEQLKtGgmblHGOcLa7qzrKNLwbqyYZD7qPlSKK6DwJiF773tdB OgdQ== 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=GYX4U0JistxADr9+dwzWwXRxSBfqo6qmSuneVJ/1Aa7X3jQlF+QSWlN8Mpnl+Y68hH u6CU3PLoaC2etnMlk61M7Riczs38C0lvj4730tfIPJ+Z1AmkVW+0Xitcv4ZZYP4xxaov CYZLjpvK7e7EuL34qKkjVorjGwIs9w0n/nT/Ev3PPRB1+RCDjTTkBDdhj6RXNx6Xkc26 G2eWcvAuwiJ01p8W8iIjQxTtHfaAqXHQPDJvK42BBGFN7pKobtfjfHpgE9lXqMFMvV1D GXq2n0yZ7ABL+oPePqMsMgDF20IFa6BjPK+NpTA41ySy0bHzqI8/eisMJyuEXvLSzni7 FeRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=hqrJxjZL; 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 s3-20020a170902c64300b001865a9586c1si293460pls.59.2022.10.19.03.06.30; Wed, 19 Oct 2022 03:06:49 -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=hqrJxjZL; 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 S233134AbiJSJUQ (ORCPT + 99 others); Wed, 19 Oct 2022 05:20:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41782 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233309AbiJSJSQ (ORCPT ); Wed, 19 Oct 2022 05:18:16 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 01BE7D9977; Wed, 19 Oct 2022 02:07:39 -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 6588A617F1; Wed, 19 Oct 2022 09:06:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7C631C433D7; Wed, 19 Oct 2022 09:06:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666170406; bh=1Y7qpSB/p47Zdgo29zn1EKjizf5xN3DqjUZFK+QYqKQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hqrJxjZLYMe32NBRt0lQAHjx5yiltiJGgJWcJdOezvyWXHE8+IHa170HuvW0cGKcB 5q1eIiVl3L7NLgW5vKEXxTfdWE0JAC86SYfATMcVVfUCtgMG0GAalm3xe9VtALTV2e FEjocvzD9qKgFTj5uIk3Y5uxO6aT0DkSPCSLdm/E= 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 6.0 598/862] clk: imx: scu: fix memleak on platform_device_add() fails Date: Wed, 19 Oct 2022 10:31:25 +0200 Message-Id: <20221019083316.386165857@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@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.4 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