]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
can: j1939: j1939_local_ecu_get(): undo increment when j1939_local_ecu_get() fails
authorTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Sun, 24 Aug 2025 10:27:40 +0000 (19:27 +0900)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 2 Oct 2025 11:35:39 +0000 (13:35 +0200)
commit7c00006e8ca2798e7229509cfbb7eeaa2779071b
tree737610bce360942b353e098117b06f23aa60ee0f
parent89145d6acdf8eb329d645fcbe1d713192298e4ab
can: j1939: j1939_local_ecu_get(): undo increment when j1939_local_ecu_get() fails

[ Upstream commit 06e02da29f6f1a45fc07bd60c7eaf172dc21e334 ]

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>
Link: https://patch.msgid.link/e7f80046-4ff7-4ce2-8ad8-7c3c678a42c9@I-love.SAKURA.ne.jp
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/can/j1939/bus.c