* [PATCH] can: j1939: undo increment when j1939_local_ecu_get() fails
@ 2025-08-24 10:27 Tetsuo Handa
2025-09-05 8:31 ` Oleksij Rempel
2025-09-09 11:54 ` Marc Kleine-Budde
0 siblings, 2 replies; 5+ messages in thread
From: Tetsuo Handa @ 2025-08-24 10:27 UTC (permalink / raw)
To: Robin van der Gracht, Oleksij Rempel, kernel, Oliver Hartkopp,
Marc Kleine-Budde, Maxime Jayat, Elenita Hinds, Bastian Stender,
linux-can, LKML
Since j1939_sk_bind() and j1939_sk_release() call j1939_local_ecu_put()
when J1939_SOCK_BOUND was already set, but the error handling path for
j1939_sk_bind() will not set J1939_SOCK_BOUND when j1939_local_ecu_get()
fails, j1939_local_ecu_get() needs to undo priv->ents[sa].nusers++ when
j1939_local_ecu_get() returns an error.
Fixes: 9d71dd0c7009 ("can: add support of SAE J1939 protocol")
Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
---
net/can/j1939/bus.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/net/can/j1939/bus.c b/net/can/j1939/bus.c
index 39844f14eed8..797719cb227e 100644
--- a/net/can/j1939/bus.c
+++ b/net/can/j1939/bus.c
@@ -290,8 +290,11 @@ int j1939_local_ecu_get(struct j1939_priv *priv, name_t name, u8 sa)
if (!ecu)
ecu = j1939_ecu_create_locked(priv, name);
err = PTR_ERR_OR_ZERO(ecu);
- if (err)
+ if (err) {
+ if (j1939_address_is_unicast(sa))
+ priv->ents[sa].nusers--;
goto done;
+ }
ecu->nusers++;
/* TODO: do we care if ecu->addr != sa? */
--
2.51.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] can: j1939: undo increment when j1939_local_ecu_get() fails
2025-08-24 10:27 [PATCH] can: j1939: undo increment when j1939_local_ecu_get() fails Tetsuo Handa
@ 2025-09-05 8:31 ` Oleksij Rempel
2025-09-07 7:42 ` Tetsuo Handa
2025-09-09 11:54 ` Marc Kleine-Budde
1 sibling, 1 reply; 5+ messages in thread
From: Oleksij Rempel @ 2025-09-05 8:31 UTC (permalink / raw)
To: Tetsuo Handa
Cc: Robin van der Gracht, kernel, Oliver Hartkopp, Marc Kleine-Budde,
Maxime Jayat, Elenita Hinds, Bastian Stender, linux-can, LKML
On Sun, Aug 24, 2025 at 07:27:40PM +0900, Tetsuo Handa wrote:
> Since j1939_sk_bind() and j1939_sk_release() call j1939_local_ecu_put()
> when J1939_SOCK_BOUND was already set, but the error handling path for
> j1939_sk_bind() will not set J1939_SOCK_BOUND when j1939_local_ecu_get()
> fails, j1939_local_ecu_get() needs to undo priv->ents[sa].nusers++ when
> j1939_local_ecu_get() returns an error.
>
> Fixes: 9d71dd0c7009 ("can: add support of SAE J1939 protocol")
> Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Tested-by: Oleksij Rempel <o.rempel@pengutronix.de>
Acked-by: Oleksij Rempel <o.rempel@pengutronix.de>
Thank you!
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] can: j1939: undo increment when j1939_local_ecu_get() fails
2025-09-05 8:31 ` Oleksij Rempel
@ 2025-09-07 7:42 ` Tetsuo Handa
2025-09-08 4:57 ` Oleksij Rempel
0 siblings, 1 reply; 5+ messages in thread
From: Tetsuo Handa @ 2025-09-07 7:42 UTC (permalink / raw)
To: Oleksij Rempel; +Cc: linux-can
On 2025/09/05 17:31, Oleksij Rempel wrote:
> On Sun, Aug 24, 2025 at 07:27:40PM +0900, Tetsuo Handa wrote:
>> Since j1939_sk_bind() and j1939_sk_release() call j1939_local_ecu_put()
>> when J1939_SOCK_BOUND was already set, but the error handling path for
>> j1939_sk_bind() will not set J1939_SOCK_BOUND when j1939_local_ecu_get()
>> fails, j1939_local_ecu_get() needs to undo priv->ents[sa].nusers++ when
>> j1939_local_ecu_get() returns an error.
>>
>> Fixes: 9d71dd0c7009 ("can: add support of SAE J1939 protocol")
>> Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
>
> Tested-by: Oleksij Rempel <o.rempel@pengutronix.de>
> Acked-by: Oleksij Rempel <o.rempel@pengutronix.de>
>
> Thank you!
Thank you for responding.
Do I need to take some action (e.g. sending to netdev@vger.kernel.org )
on these three patches?
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] can: j1939: undo increment when j1939_local_ecu_get() fails
2025-09-07 7:42 ` Tetsuo Handa
@ 2025-09-08 4:57 ` Oleksij Rempel
0 siblings, 0 replies; 5+ messages in thread
From: Oleksij Rempel @ 2025-09-08 4:57 UTC (permalink / raw)
To: Tetsuo Handa; +Cc: linux-can
On Sun, Sep 07, 2025 at 04:42:33PM +0900, Tetsuo Handa wrote:
> On 2025/09/05 17:31, Oleksij Rempel wrote:
> > On Sun, Aug 24, 2025 at 07:27:40PM +0900, Tetsuo Handa wrote:
> >> Since j1939_sk_bind() and j1939_sk_release() call j1939_local_ecu_put()
> >> when J1939_SOCK_BOUND was already set, but the error handling path for
> >> j1939_sk_bind() will not set J1939_SOCK_BOUND when j1939_local_ecu_get()
> >> fails, j1939_local_ecu_get() needs to undo priv->ents[sa].nusers++ when
> >> j1939_local_ecu_get() returns an error.
> >>
> >> Fixes: 9d71dd0c7009 ("can: add support of SAE J1939 protocol")
> >> Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
> >
> > Tested-by: Oleksij Rempel <o.rempel@pengutronix.de>
> > Acked-by: Oleksij Rempel <o.rempel@pengutronix.de>
> >
> > Thank you!
>
> Thank you for responding.
> Do I need to take some action (e.g. sending to netdev@vger.kernel.org )
> on these three patches?
Nothing is needed for now. As soon as CAN maintainers will have time to
take look at it, the patches will be taken or changes may be requested.
Best Regards,
Oleksij
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] can: j1939: undo increment when j1939_local_ecu_get() fails
2025-08-24 10:27 [PATCH] can: j1939: undo increment when j1939_local_ecu_get() fails Tetsuo Handa
2025-09-05 8:31 ` Oleksij Rempel
@ 2025-09-09 11:54 ` Marc Kleine-Budde
1 sibling, 0 replies; 5+ messages in thread
From: Marc Kleine-Budde @ 2025-09-09 11:54 UTC (permalink / raw)
To: Tetsuo Handa
Cc: Robin van der Gracht, Oleksij Rempel, kernel, Oliver Hartkopp,
Maxime Jayat, Elenita Hinds, Bastian Stender, linux-can, LKML
[-- Attachment #1: Type: text/plain, Size: 837 bytes --]
On 24.08.2025 19:27:40, Tetsuo Handa wrote:
> Since j1939_sk_bind() and j1939_sk_release() call j1939_local_ecu_put()
> when J1939_SOCK_BOUND was already set, but the error handling path for
> j1939_sk_bind() will not set J1939_SOCK_BOUND when j1939_local_ecu_get()
> fails, j1939_local_ecu_get() needs to undo priv->ents[sa].nusers++ when
> j1939_local_ecu_get() returns an error.
>
> Fixes: 9d71dd0c7009 ("can: add support of SAE J1939 protocol")
> Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Applied to linux-can.
regards,
Marc
--
Pengutronix e.K. | Marc Kleine-Budde |
Embedded Linux | https://www.pengutronix.de |
Vertretung Nürnberg | Phone: +49-5121-206917-129 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-9 |
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-09-09 11:54 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-24 10:27 [PATCH] can: j1939: undo increment when j1939_local_ecu_get() fails Tetsuo Handa
2025-09-05 8:31 ` Oleksij Rempel
2025-09-07 7:42 ` Tetsuo Handa
2025-09-08 4:57 ` Oleksij Rempel
2025-09-09 11:54 ` Marc Kleine-Budde
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox