From nobody Fri Oct 17 12:01:43 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 313AEC43217 for ; Wed, 19 Oct 2022 09:20:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233208AbiJSJUR (ORCPT ); Wed, 19 Oct 2022 05:20:17 -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-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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.c= om 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); =20 - platform_device_add(pdev); + ret =3D platform_device_add(pdev); + if (ret) { + platform_device_put(pdev); + return ERR_PTR(ret); + } =20 /* For API backwards compatiblilty, simply return NULL for success */ return NULL; --=20 2.35.1