Skip to content

Commit deedea5

Browse files
Tetsuo Handagregkh
authored andcommitted
can: j1939: j1939_local_ecu_get(): undo increment when j1939_local_ecu_get() fails
[ Upstream commit 06e02da ] 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: 9d71dd0 ("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>
1 parent 1e1adff commit deedea5

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

net/can/j1939/bus.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,8 +290,11 @@ int j1939_local_ecu_get(struct j1939_priv *priv, name_t name, u8 sa)
290290
if (!ecu)
291291
ecu = j1939_ecu_create_locked(priv, name);
292292
err = PTR_ERR_OR_ZERO(ecu);
293-
if (err)
293+
if (err) {
294+
if (j1939_address_is_unicast(sa))
295+
priv->ents[sa].nusers--;
294296
goto done;
297+
}
295298

296299
ecu->nusers++;
297300
/* TODO: do we care if ecu->addr != sa? */

0 commit comments

Comments
 (0)