* [PATCH] net: ipa: Fix valid_state leak in ipa_smp2p_init()
@ 2026-09-17 11:54 Wentao Liang
2026-09-17 12:14 ` Greg KH
2026-09-17 12:18 ` Alex Elder
0 siblings, 2 replies; 4+ messages in thread
From: Wentao Liang @ 2026-09-17 11:54 UTC (permalink / raw)
To: andrew+netdev
Cc: davem, edumazet, elder, kuba, linux-kernel, netdev, pabeni,
Wentao Liang, stable
qcom_smem_state_get() takes a reference on the state, but
ipa_smp2p_init() returns without releasing the "ipa-clock-enabled-valid"
state when the bit number is out of range, when the "ipa-clock-enabled"
state cannot be acquired or its bit number is out of range, when the
smp2p structure cannot be allocated, and on the error paths that free
the structure. Release the reference on all of these paths.
Fixes: 530f9216a953 ("soc: qcom: ipa: AP/modem communications")
Cc: stable@vger.kernel.org
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
drivers/net/ipa/ipa_smp2p.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ipa/ipa_smp2p.c b/drivers/net/ipa/ipa_smp2p.c
index 78f6df2cad76..f45225b16722 100644
--- a/drivers/net/ipa/ipa_smp2p.c
+++ b/drivers/net/ipa/ipa_smp2p.c
@@ -232,21 +232,27 @@ ipa_smp2p_init(struct ipa *ipa, struct platform_device *pdev, bool modem_init)
&valid_bit);
if (IS_ERR(valid_state))
return PTR_ERR(valid_state);
- if (valid_bit >= 32) /* BITS_PER_U32 */
+ if (valid_bit >= 32) { /* BITS_PER_U32 */
+ qcom_smem_state_put(valid_state);
return -EINVAL;
+ }
enabled_state = qcom_smem_state_get(dev, "ipa-clock-enabled",
&enabled_bit);
- if (IS_ERR(enabled_state))
+ if (IS_ERR(enabled_state)) {
+ qcom_smem_state_put(valid_state);
return PTR_ERR(enabled_state);
+ }
if (enabled_bit >= 32) { /* BITS_PER_U32 */
qcom_smem_state_put(enabled_state);
+ qcom_smem_state_put(valid_state);
return -EINVAL;
}
smp2p = kzalloc_obj(*smp2p);
if (!smp2p) {
qcom_smem_state_put(enabled_state);
+ qcom_smem_state_put(valid_state);
return -ENOMEM;
}
@@ -293,6 +299,7 @@ ipa_smp2p_init(struct ipa *ipa, struct platform_device *pdev, bool modem_init)
ipa->smp2p = NULL;
mutex_destroy(&smp2p->mutex);
qcom_smem_state_put(enabled_state);
+ qcom_smem_state_put(valid_state);
kfree(smp2p);
return ret;
--
2.34.1
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] net: ipa: Fix valid_state leak in ipa_smp2p_init()
2026-09-17 11:54 [PATCH] net: ipa: Fix valid_state leak in ipa_smp2p_init() Wentao Liang
@ 2026-09-17 12:14 ` Greg KH
2026-11-08 10:29 ` Wentao Liang
2026-09-17 12:18 ` Alex Elder
1 sibling, 1 reply; 4+ messages in thread
From: Greg KH @ 2026-09-17 12:14 UTC (permalink / raw)
To: Wentao Liang
Cc: andrew+netdev, davem, edumazet, elder, kuba, linux-kernel,
netdev, pabeni, stable
On Thu, Sep 17, 2026 at 11:54:24AM +0000, Wentao Liang wrote:
> qcom_smem_state_get() takes a reference on the state, but
> ipa_smp2p_init() returns without releasing the "ipa-clock-enabled-valid"
> state when the bit number is out of range, when the "ipa-clock-enabled"
> state cannot be acquired or its bit number is out of range, when the
> smp2p structure cannot be allocated, and on the error paths that free
> the structure. Release the reference on all of these paths.
>
> Fixes: 530f9216a953 ("soc: qcom: ipa: AP/modem communications")
> Cc: stable@vger.kernel.org
> Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
> ---
> drivers/net/ipa/ipa_smp2p.c | 11 +++++++++--
> 1 file changed, 9 insertions(+), 2 deletions(-)
Did you forget the Assisted-by: tag?
Please reply to all of your sent patches and fix that up with new
versions.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] net: ipa: Fix valid_state leak in ipa_smp2p_init()
2026-09-17 12:14 ` Greg KH
@ 2026-11-08 10:29 ` Wentao Liang
0 siblings, 0 replies; 4+ messages in thread
From: Wentao Liang @ 2026-11-08 10:29 UTC (permalink / raw)
To: Greg KH
Cc: Alex Elder, andrew+netdev, davem, edumazet, elder, kuba,
linux-kernel, netdev, pabeni, vulab
Hi Greg, Alex,
Sorry for the very late reply to both of you, and for the extra work this
caused.
Alex, you are right that 96ca1e658ae45 ("net: ipa: fix SMEM state handle
leaks in SMP2P init") already covers this. It releases both SMEM state
handles on the init error paths and in ipa_smp2p_exit(), and it has been
in mainline since v7.2-rc2. My patch duplicates it, was incomplete on
its own, and was generated from an old snapshot (v7.1-rc4 based), which
is why its context does not match v7.2. There is nothing left to fix, so
please disregard it; the patchwork entry already shows as not applicable.
Greg, I owe you an answer on the Assisted-by tag, and I am sorry for
leaving it hanging. The candidate came from our static analysis tooling,
and DeepSeek and GPT-6.1 Sol were used to audit the finding and help
write the change; I reviewed the result and I am responsible for what I
sent. I should have declared that in the changelog itself, and I did
not. I have re-read Documentation/process/generated-content.rst on this
and will state the tools used in the changelog text from now on.
Since all three changes here are already upstream, there is no v2 to
send. On the volume: you are right, I sent far more patches than I could
follow up on, and the review time that cost is on me. This has been an
important lesson. I am now going through all of the outstanding feedback
on every patch I sent, by hand, thread by thread, and I will answer each
one. I will not post patches in batches larger than I can personally
review and follow up on.
Thanks,
Wentao
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] net: ipa: Fix valid_state leak in ipa_smp2p_init()
2026-09-17 11:54 [PATCH] net: ipa: Fix valid_state leak in ipa_smp2p_init() Wentao Liang
2026-09-17 12:14 ` Greg KH
@ 2026-09-17 12:18 ` Alex Elder
1 sibling, 0 replies; 4+ messages in thread
From: Alex Elder @ 2026-09-17 12:18 UTC (permalink / raw)
To: Wentao Liang, andrew+netdev
Cc: davem, edumazet, elder, kuba, linux-kernel, netdev, pabeni, stable
On 9/17/26 6:54 AM, Wentao Liang wrote:
> qcom_smem_state_get() takes a reference on the state, but
> ipa_smp2p_init() returns without releasing the "ipa-clock-enabled-valid"
> state when the bit number is out of range, when the "ipa-clock-enabled"
> state cannot be acquired or its bit number is out of range, when the
> smp2p structure cannot be allocated, and on the error paths that free
> the structure. Release the reference on all of these paths.
I haven't looked very closely at this one but it also seems
to have been fixed already.
96ca1e658ae45 net: ipa: fix SMEM state handle leaks in SMP2P init
-Alex
>
> Fixes: 530f9216a953 ("soc: qcom: ipa: AP/modem communications")
> Cc: stable@vger.kernel.org
> Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
> ---
> drivers/net/ipa/ipa_smp2p.c | 11 +++++++++--
> 1 file changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/ipa/ipa_smp2p.c b/drivers/net/ipa/ipa_smp2p.c
> index 78f6df2cad76..f45225b16722 100644
> --- a/drivers/net/ipa/ipa_smp2p.c
> +++ b/drivers/net/ipa/ipa_smp2p.c
> @@ -232,21 +232,27 @@ ipa_smp2p_init(struct ipa *ipa, struct platform_device *pdev, bool modem_init)
> &valid_bit);
> if (IS_ERR(valid_state))
> return PTR_ERR(valid_state);
> - if (valid_bit >= 32) /* BITS_PER_U32 */
> + if (valid_bit >= 32) { /* BITS_PER_U32 */
> + qcom_smem_state_put(valid_state);
> return -EINVAL;
> + }
>
> enabled_state = qcom_smem_state_get(dev, "ipa-clock-enabled",
> &enabled_bit);
> - if (IS_ERR(enabled_state))
> + if (IS_ERR(enabled_state)) {
> + qcom_smem_state_put(valid_state);
> return PTR_ERR(enabled_state);
> + }
> if (enabled_bit >= 32) { /* BITS_PER_U32 */
> qcom_smem_state_put(enabled_state);
> + qcom_smem_state_put(valid_state);
> return -EINVAL;
> }
>
> smp2p = kzalloc_obj(*smp2p);
> if (!smp2p) {
> qcom_smem_state_put(enabled_state);
> + qcom_smem_state_put(valid_state);
> return -ENOMEM;
> }
>
> @@ -293,6 +299,7 @@ ipa_smp2p_init(struct ipa *ipa, struct platform_device *pdev, bool modem_init)
> ipa->smp2p = NULL;
> mutex_destroy(&smp2p->mutex);
> qcom_smem_state_put(enabled_state);
> + qcom_smem_state_put(valid_state);
> kfree(smp2p);
>
> return ret;
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-11-08 10:40 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-17 11:54 [PATCH] net: ipa: Fix valid_state leak in ipa_smp2p_init() Wentao Liang
2026-09-17 12:14 ` Greg KH
2026-11-08 10:29 ` Wentao Liang
2026-09-17 12:18 ` Alex Elder
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®