Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp4447910imw; Tue, 19 Jul 2022 06:50:42 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vbiSWhRsO3bSi21YBYyx9M+WNd47DjLCRz7vXyxI2qhlBiNT+1mn5TuhBa4yeEuffFgGWx X-Received: by 2002:a0c:c445:0:b0:473:c50e:e0b1 with SMTP id t5-20020a0cc445000000b00473c50ee0b1mr11420044qvi.94.1658238642018; Tue, 19 Jul 2022 06:50:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658238642; cv=none; d=google.com; s=arc-20160816; b=H6H0nkDsoWqVY5UCIohjLPRYBzI//wH3n/4HxsflotIBX13vx+bU0HcarwvjN9g3Ey N9Z71Jr1bQvoVAbPWeEFny9T3V0hb/zwbqNN4LteqqWRwjzmOXHFOoZ18ruW4PAGelM9 wHUM3wE4bKuqdyk8ef6m/6haTCejKvsusX63baHLtomcTNTShWN1Q7bOLEwgojM6R9RD +ByJCUtah3nLzp18C/H+vGfj485Mtm7aBTkG+3Ei+273vqrYsWzcuIhBegYr4pFuMwf9 VCqU+MmPHvgvQugN2PixSCcKSEcekfDSIFl6CruxlkHFe6HqfPTxh2ZJEcxN6LB2CEFA GA4w== 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=5JVIJEmCZ8Rg8wXpSk18xrIUL+Q/Qz5hDWalb5Zn82w=; b=ioamHJFvytCcm8z4M+IVcfW5kjtXwpK6sIjIXRujer+l/4SIEvZl8WRF46AsGt6lOo WWoXhVRDpv140GRlQ6nF9PzdTzrtJUXBQee6TMagtV7uEKCCP7IYrO6QUbAlJaunq5CC DNy+JKCxO5Uh+iY2KGWZcQOM+RL0LSRNngJ9JFpWkuT6qlKYfxwAZkUugvSO5wLRWeiT ZCOmxFdC/QcwKdRq2c30oU78WPrBue+7y9N8la59CQ5uADu7mMjL4KXtNonYvvt8pzF3 bnxQlKqhhKs6fOJd/HAoDfHjL0vv31FA0i6kElEzoGmcn8QuE97Uv421Wak633391hyr fphg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=bST29rlP; 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 fd14-20020a05622a4d0e00b0031eddc773a2si4999084qtb.142.2022.07.19.06.50.27; Tue, 19 Jul 2022 06:50:42 -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=bST29rlP; 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 S239797AbiGSMZs (ORCPT + 99 others); Tue, 19 Jul 2022 08:25:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40516 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240006AbiGSMY2 (ORCPT ); Tue, 19 Jul 2022 08:24:28 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9774261D42; Tue, 19 Jul 2022 05:09:18 -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 ams.source.kernel.org (Postfix) with ESMTPS id 0D800B81B2B; Tue, 19 Jul 2022 12:08:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6A6AEC341C6; Tue, 19 Jul 2022 12:08:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658232527; bh=tDavWp/OijAssTT8TolwZcclYl6hiOCLRtRXjqj/hW8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bST29rlPFAXraNgq/5SzZHcLh1oUIo0rSVeXYWnU6xKZX0Hj7yuh/5DjPZ2h1itUr 0k6R6NBhG2W8cF/j4VAnrOkYPrhiD4SiFZNd9tmITTx0YXrHU8+DgOH9DsODddBBZq WrpjZ+guOie6AZyYS0qFjetvV8pmBT5I8GqcZXmU= 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.10 087/112] net: sfp: fix memory leak in sfp_probe() Date: Tue, 19 Jul 2022 13:54:20 +0200 Message-Id: <20220719114635.091923514@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220719114626.156073229@linuxfoundation.org> References: <20220719114626.156073229@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 96068e0d841a..dcbe278086dc 100644 --- a/drivers/net/phy/sfp.c +++ b/drivers/net/phy/sfp.c @@ -2427,7 +2427,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