From patchwork Wed Oct 19 08:31:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 4823 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp223474wrs; Wed, 19 Oct 2022 02:37:37 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4OIJrWd/iONHsyS+QeXD8bSFAtxM6LEOZ/NW+claRQWuv5Aezx6P0/7cZHINR43Ze9Jlja X-Received: by 2002:a17:906:8a55:b0:78d:b6db:a2d4 with SMTP id gx21-20020a1709068a5500b0078db6dba2d4mr5983164ejc.82.1666172247101; Wed, 19 Oct 2022 02:37:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666172247; cv=none; d=google.com; s=arc-20160816; b=OIARls6Q9APTc6bXdrKBzr3MUxwbUKFxNxr5+bGDG7n4VvU0s9A5ivy0jZvAVYhFar NJLTJ/D2MVfEErzxTW+k7CSiOiegMekMsqHOt5eh78XbjHYit4MuXAm2+k+3t+I0FM4l nciG9C9OxZkSP8Bvybb0nKNAUz5imzQoJjGhFw6n9ZfTMkJvzSVNjIGPUCjTA3uzYdxE NPP94c8lrVOTqnbxeYVvdRrqMnLdh4WS0Br4XDQBalPc0QSm6t8rShqNjnd78dCwKq27 ZvC/IZg+w71KcEVZpOXkONT0skPFUHG8eOVloseNV9wdUe5OskYl8buepYoqySsJt5U5 c2tw== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v15-20020a170906180f00b0078d20d71475si11997235eje.413.2022.10.19.02.37.01; Wed, 19 Oct 2022 02:37:27 -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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747108230468494614?= X-GMAIL-MSGID: =?utf-8?q?1747108230468494614?= 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;