From mboxrd@z Thu Jan 1 00:00:00 1970 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 C9F41C32771 for ; Mon, 26 Sep 2022 09:13:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234687AbiIZJNU (ORCPT ); Mon, 26 Sep 2022 05:13:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48828 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233673AbiIZJNS (ORCPT ); Mon, 26 Sep 2022 05:13:18 -0400 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B13CD3BC7C; Mon, 26 Sep 2022 02:13:16 -0700 (PDT) Received: from dggpeml500022.china.huawei.com (unknown [172.30.72.55]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4MbcPn4KZPz1P6p8; Mon, 26 Sep 2022 17:09:01 +0800 (CST) Received: from dggpeml500010.china.huawei.com (7.185.36.155) by dggpeml500022.china.huawei.com (7.185.36.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Mon, 26 Sep 2022 17:13:14 +0800 Received: from [10.67.111.232] (10.67.111.232) by dggpeml500010.china.huawei.com (7.185.36.155) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Mon, 26 Sep 2022 17:13:14 +0800 Message-ID: <3b7e7b14-d7bd-4d58-3ace-d243c4f038d9@huawei.com> Date: Mon, 26 Sep 2022 17:13:02 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.10.0 Subject: Re: [PATCH -next] clk: imx: scu: fix memleak on platform_device_add() fails From: "linyujun (C)" To: , , , , , , , , CC: , , References: <20220914033206.98046-1-linyujun809@huawei.com> In-Reply-To: <20220914033206.98046-1-linyujun809@huawei.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.67.111.232] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpeml500010.china.huawei.com (7.185.36.155) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org kindly ping 在 2022/9/14 11:32, Lin Yujun 写道: > 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 > --- > 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;