From nobody Fri Dec 19 16:01:22 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 9E550C38A2D for ; Mon, 24 Oct 2022 14:06:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232491AbiJXOGy (ORCPT ); Mon, 24 Oct 2022 10:06:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46842 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236212AbiJXOC7 (ORCPT ); Mon, 24 Oct 2022 10:02:59 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D7572C0997; Mon, 24 Oct 2022 05:48:46 -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 51A08612B4; Mon, 24 Oct 2022 12:48:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 64312C433C1; Mon, 24 Oct 2022 12:48:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666615718; bh=WDyOXrbFl1uJd00F4JRhGGH67hz1LHgixA315HYy2mI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1Z2wo+4u60gkC0ziDgX8NdFYLaAwkLmPoRFHwRfvdlDnc2vJtDPvvze/WkJOUFmqs RdxrJXXkfWIoxM0nJN/0j5j0IeEBDNtBxKJL4QY39BlFtVMJyfbCSi3dmKgOdrfU6w iAzICO8P/m9vtStRXxCOlP+/BujjI7I/YT49gH5M= 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.15 356/530] clk: imx: scu: fix memleak on platform_device_add() fails Date: Mon, 24 Oct 2022 13:31:40 +0200 Message-Id: <20221024113101.141484836@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113044.976326639@linuxfoundation.org> References: <20221024113044.976326639@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 083da31dc3ea..dc933fd5d5a0 100644 --- a/drivers/clk/imx/clk-scu.c +++ b/drivers/clk/imx/clk-scu.c @@ -690,7 +690,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