From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtpout-04.galae.net (smtpout-04.galae.net [185.171.202.116]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C8DE93909B9 for ; Mon, 19 Oct 2026 09:31:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.171.202.116 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1792402283; cv=none; b=N27gwUFxcHcjvMEp+u3iO1+iZAHDwZ/CHUmNqrd4fzQY1SRDirZMyVCIoIHiIL9XVDXu9V5twTVMJ6nhn7pKndHAZtC9fhg/MUkYFuzDs9yglOHfj4oREExLez9mmoCFfCotFv9kvtal+Pfrc7Fh2snGv/OK7mBjbuDxre2EEqc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1792402283; c=relaxed/simple; bh=LkCV4e9PnURAIXIJVZKGnMMtbhVbo7rALVk+tpoSUdE=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=EU+2NeE66CWrz3Cet/PL26BOQvbXh9saVmFGOzw2rb4XpOdm5DZv4BHfigrmhvHVcTcvU8shskaepNMpUVJAN1V3gsp0tYh+ISVsP+tE1jl0UTrDZKh3posudU23+P/O5frGeLMi7AUphCQEueO2RpJzGFTyzrJWgd7DixT70W4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=1W3UXTsr; arc=none smtp.client-ip=185.171.202.116 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="1W3UXTsr" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-04.galae.net (Postfix) with ESMTPS id 3C9E5C653EB; Mon, 19 Oct 2026 09:32:17 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 2944360582; Mon, 19 Oct 2026 09:31:19 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 4C03C10328429; Mon, 19 Oct 2026 11:31:13 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1792402278; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:content-language:in-reply-to:references; bh=X2xD/Phx8CqyDpzsBmaRAmFFK3I+L4V+k6eK0h6K8Xs=; b=1W3UXTsrothYUJSklRhLHuh+wv95KYjxau/JriMWgyDirxaBw1I63Hi7mDx/+mHcfR8zQg T6UIf43E6vKTtZdAHNORa14RZkjbW1SL0Cem8kTE1x3IVfv4UYDeMUHNKL//LySg42S0eS gmQSQwRI6BBQLGJNALFO0g3tgSKq6arjtsfFZtT+Un1QzDsv0+wYLZAllTFBSc84/i+YDk UDWCUtNqMorMvcGdoEFCMR6MBIZ/pNTjWaYCosfuUy/Nt3KQf0yMsR+Boqwg4X8W7TY+XM vWZ0sbc+c6p6pnkN2MEea5MHw4dWYa76ytL6NbD2+r0CZCbfKc1qP4LPoc0k1A== Message-ID: Date: Mon, 19 Oct 2026 11:31:12 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Betterbird (Linux) Subject: Re: [PATCH net 02/10] net: pse-pd: fix module refcount leak in pse_control_get_internal() To: Carlo Szelinsky , Oleksij Rempel , Andrew Lunn , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Piotr Kubik , Sai Krishna , Simon Horman , Kyle Swenson , netdev-bot+sashiko@kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org References: <20261018082314.48950-1-github@szelinsky.de> <20261018082314.48950-3-github@szelinsky.de> From: Kory Maincent Content-Language: en-US In-Reply-To: <20261018082314.48950-3-github@szelinsky.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Last-TLS-Session-Version: TLSv1.3 On 10/18/26 10:23, Carlo Szelinsky wrote: > pse_control_get_internal() takes a module reference and then has two > error paths that skip module_put(): a controller without > pi_get_admin_state(), and a failing pse_pi_is_hw_enabled(). The second > one happens on any I2C or UART error. Each time, one more reference > leaks, and the PSE driver can no longer be unloaded. > > Send both to put_module, like the regulator_get_exclusive() error path. > > Fixes: ffef61d6d273 ("net: pse-pd: Add support for budget evaluation strategies") > Signed-off-by: Carlo Szelinsky As spotted by sashiko you can remove the two checks on pi_get_admin_state callback as it is already done in the pse_controller_register() function. Maybe you can do it in a patch before this one even if it is not a fix. With this change: Reviewed-by: Kory Maincent Thank you! > --- > drivers/net/pse-pd/pse_core.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/net/pse-pd/pse_core.c b/drivers/net/pse-pd/pse_core.c > index c0573cbbba5b..1710f9bb7d27 100644 > --- a/drivers/net/pse-pd/pse_core.c > +++ b/drivers/net/pse-pd/pse_core.c > @@ -1427,7 +1427,7 @@ pse_control_get_internal(struct pse_controller_dev *pcdev, unsigned int index, > > if (!pcdev->ops->pi_get_admin_state) { > ret = -EOPNOTSUPP; > - goto free_psec; > + goto put_module; > } > > /* Initialize admin_state_enabled before the regulator_get. This > @@ -1436,7 +1436,7 @@ pse_control_get_internal(struct pse_controller_dev *pcdev, unsigned int index, > */ > ret = pse_pi_is_hw_enabled(pcdev, index); > if (ret < 0) > - goto free_psec; > + goto put_module; > > pcdev->pi[index].admin_state_enabled = ret; > psec->ps = regulator_get_exclusive(pcdev->dev, -- Köry Maincent, Bootlin Embedded Linux and kernel engineering https://bootlin.com