Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp4449855imw; Tue, 19 Jul 2022 06:53:04 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sD9CPzn6MHj8PzudJCswN3bWOvJ0OsogD5meb36HnO4SuOhU5SZg+xH/cbwm0c7Luc2iqc X-Received: by 2002:a05:6402:4244:b0:43a:ded8:563b with SMTP id g4-20020a056402424400b0043aded8563bmr45068491edb.222.1658238783884; Tue, 19 Jul 2022 06:53:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658238783; cv=none; d=google.com; s=arc-20160816; b=NGUTjz59ikSUDWcVj0p3Tzx0LYcvvf9Ze2ecQOA2JwOEik+/7NxVR8e0h9V7Qdbp1+ dZL0mXbam3hwOfE1dzkJJtfcuM3otSrgYvH/amNjP70wQHZ+pLJd0ux8l+aHDmdBZeSq 61bpu66cy/5AiQs+nE9Nl0lGBWkabDauUaVSZXymF8GN4noHBvEstaud0pl5/t+zlfj2 dex/HHVkSJLk4S6ZpHZfsmnCJcXnFyUAN7tm8QswAXNP85ejm0LlAL2e8oTmbMt/6+z9 5fUX7PosG+78itSXgpUtCoX2wz/Y7sTCH9bnAQEX4XFeQx4Q7NhCzDZrIs5S7CWbmnI+ WMYQ== 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=56i8pDzxGGPIX7BOkFotyOHbL7DHomMeGG4GOkwVnEI=; b=l7KsFxu6z8mSF0BT6ElskASSMz++mJqJidY5ud+QRSdqzr0hpIoK4UMVBmqw8B2T43 OYJ74xJUViW49KFzcN/vr3aCHDF5eEacnd49Ea9eAn1gVOJbDUHoQJ9qxHnVGd0EvERu mkpuIx7YUIR0Xd7MbAitaNJQQK5GT+Cfwc8M0Q7txfd0Y6IBha0Lp17PU4ptbtEWocQP iF4LRZRedp5ePRjjKCbf72qtR84FRf7jmc9iqyLhtfyNW/C+ekNzsPiu305ZfryPgVNz GDbLv1BI7C5yXnAuDAydelkA7Kf8Lucw7zeKnnQIXzEnNDAXWOyT0t0XOzUBuOLhwh+b 0RZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=N2KaeR6K; 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 p19-20020a50cd93000000b0043a737c28desi18831165edi.279.2022.07.19.06.52.39; Tue, 19 Jul 2022 06:53:03 -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=N2KaeR6K; 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 S238456AbiGSMID (ORCPT + 99 others); Tue, 19 Jul 2022 08:08:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238436AbiGSMHd (ORCPT ); Tue, 19 Jul 2022 08:07:33 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C463B4F186; Tue, 19 Jul 2022 05:01:17 -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 37CB7616EA; Tue, 19 Jul 2022 12:01:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 13125C341C6; Tue, 19 Jul 2022 12:01:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658232075; bh=P4/m4+k8HrCpAYJh+3t/ikcjeoQhx+QcnM79o21uMYs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=N2KaeR6K4BzjGRyvLM14FUB4pUoR9EhvBrlheKu+Pw+vIIYAQImxDSKrsi8ZSOZMi 0Lkr9ABTUlGfdAw5ht3MPcy3TaboOHYlL+IcLY9iqBhwJ7sk9Bd7QFWz0SHPtuwugq DQ8uz19DhrYdPFBL9bdAalxZTCEulPGtAIJevhG4= 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 4.19 34/48] net: sfp: fix memory leak in sfp_probe() Date: Tue, 19 Jul 2022 13:54:11 +0200 Message-Id: <20220719114522.910453356@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220719114518.915546280@linuxfoundation.org> References: <20220719114518.915546280@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 71bafc8f5ed0..e7af73ad8a44 100644 --- a/drivers/net/phy/sfp.c +++ b/drivers/net/phy/sfp.c @@ -1811,7 +1811,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