Re: [PATCH] can: j1939: return 0 instead of user value in j1939_sk_setsockopt_flag()
From: Oleksij Rempel
Date: Fri Nov 27 2026 - 06:19:57 EST
Hi Hui,
thank you, and sorry for the long silence.
On Sat, Sep 19, 2026 at 09:36:32PM +0000, Hui Peng wrote:
> In `j1939_sk_setsockopt_flag()`, after copying the integer option value
> `tmp` from userspace and updating `jsk->state`, the function returns
> `tmp` instead of `0`.
>
> If a caller passes a negative integer (e.g., `-1`) to enable
> `SO_J1939_BROADCAST` or `SO_J1939_PROMISC`, `if (tmp)` sets `jsk->state
> |= flag` and then returns the negative value as an error code from
> `setsockopt()`. If a caller passes a positive non-zero integer (e.g.,
> `1`), `setsockopt()` violates POSIX by returning `1` instead of `0`.
>
> Return `0` on success in `j1939_sk_setsockopt_flag()`.
>
> Fixes: 9d71dd0c7009 ("can: add support of SAE J1939 protocol")
> Assisted-by: LLM
> Signed-off-by: Hui Peng <benquike@xxxxxxxxx>
Acked-by: Oleksij Rempel <o.rempel@xxxxxxxxxxxxxx>
For next time: CAN patches go to linux-can and the CAN maintainers
only, please do not send them to netdev.
Regards,
Oleksij