Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp4450929imw; Tue, 19 Jul 2022 06:54:30 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tm1CMKoKLE113C7nUvb5kadkcfYw4dbHyeL7hxKw35iWWxAMxsr35S0hXdr3lMdL/M2rAK X-Received: by 2002:a05:6402:3488:b0:43a:e33d:7d26 with SMTP id v8-20020a056402348800b0043ae33d7d26mr44200194edc.279.1658238870617; Tue, 19 Jul 2022 06:54:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658238870; cv=none; d=google.com; s=arc-20160816; b=oCQmb7VylisyysC/F9ZmPMqZKSOsX/sS48PLlIwyeQmgAS4Y9ENo2Hz07JVl6iTaYG mNMH+FAu7jPGGpdSGYtb3qEKnBFjvslZE0MwsBsr6uEd3rio7DukceaCh7d0xf0Vb4EO BNLsuMWswPZoqFzKcQ8hKjpoQdy9lKr3GKRVoAdtdDwAftgd3Y/U2W2vQMdsyk91hN1R bCw57fr8SF06/UUNcUDkzVqCDPAXRnK6KOZTOz29LWuXFFV2iXkY3PtHzV4oAyjTQhTd 3Tqlb/VJhvh+iRduYD3Z65tYrd/vQJ993NazhZ/vDPfxZ2gusiXEizKdSJygEM9Q6d/Y LKLQ== 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=6FXBwzsVwJyBHif+vWm/h1P+QosB17ZhTOBjyE09XFs=; b=tdPNRmaPKkYllMlBK3Vjr++u5VS4VwyTEYK+L6XRLw2mcNceA3p43nQ//3+YnI5sqJ jhYW0qEUJYWTNcAQFudJX0WBvekJ770osF32mmGzDmMDEN01VigWTZEYPMWbFQyDNV1i QYhNS+KQ030bF5N+FPodUXawsfUPlgml5SN0Q4EQ2X1uscdOEipq7egSci4cMJIEpdyY zRHIFeLl2r6WkTulsMhllmjUeZBiBJmdFGEvPnlc6qHZ6geEiHt6Lf3OJJGpXkp4m3kn MqW5G/WRh/yK/kjAtXuHBuYzmnDR/HM0m/bnGGLUq6RbfIMRZQX9+4azaNyk3UjW+bRk 5Olg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=GZJJh6NZ; 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 b20-20020a170906709400b0072af54e038fsi17526078ejk.286.2022.07.19.06.54.05; Tue, 19 Jul 2022 06:54:30 -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=GZJJh6NZ; 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 S241479AbiGSMmR (ORCPT + 99 others); Tue, 19 Jul 2022 08:42:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241025AbiGSMkG (ORCPT ); Tue, 19 Jul 2022 08:40:06 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 087B97D1F7; Tue, 19 Jul 2022 05:16:14 -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 3DBD8617B2; Tue, 19 Jul 2022 12:16:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1AB95C341C6; Tue, 19 Jul 2022 12:16:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658232973; bh=QcGtGtCYqtma3sZUNavLiHZxpdlk17kScyhaXBAROMU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GZJJh6NZVguZVzjSQ/r2CetKMDh/6a2BVphfTkpoh1bvQxIsqiPPc8lVshMLt5+xN QP/ZqAzIqvPwCCC2gQp7uB6CfQ3GcGMHzVyIN7HMycztnPS6/cscfbEX/idLDouHO3 vhyNr286kyzgYDVib5VYWbX4ExzshaTVHtcSaqq8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jianglei Nie , "Russell King (Oracle)" , Paolo Abeni , Sasha Levin Subject: [PATCH 5.15 130/167] net: sfp: fix memory leak in sfp_probe() Date: Tue, 19 Jul 2022 13:54:22 +0200 Message-Id: <20220719114709.149050662@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220719114656.750574879@linuxfoundation.org> References: <20220719114656.750574879@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.8 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: Jianglei Nie [ Upstream commit 0a18d802d65cf662644fd1d369c86d84a5630652 ] sfp_probe() allocates a memory chunk from sfp with sfp_alloc(). When devm_add_action() fails, sfp is not freed, which leads to a memory leak. We should use devm_add_action_or_reset() instead of devm_add_action(). Signed-off-by: Jianglei Nie Reviewed-by: Russell King (Oracle) Link: https://lore.kernel.org/r/20220629075550.2152003-1-niejianglei2021@163.com Signed-off-by: Paolo Abeni Signed-off-by: Sasha Levin --- drivers/net/phy/sfp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/phy/sfp.c b/drivers/net/phy/sfp.c index 90dfefc1f5f8..028a5df5c538 100644 --- a/drivers/net/phy/sfp.c +++ b/drivers/net/phy/sfp.c @@ -2504,7 +2504,7 @@ static int sfp_probe(struct platform_device *pdev) platform_set_drvdata(pdev, sfp); - err = devm_add_action(sfp->dev, sfp_cleanup, sfp); + err = devm_add_action_or_reset(sfp->dev, sfp_cleanup, sfp); if (err < 0) return err; -- 2.35.1