]> git.baikalelectronics.ru Git - kernel.git/commit
mlxsw: spectrum_ptp: Fix validation in mlxsw_sp1_ptp_packet_finish()
authorPetr Machata <petrm@mellanox.com>
Tue, 2 Jul 2019 19:06:47 +0000 (19:06 +0000)
committerDavid S. Miller <davem@davemloft.net>
Tue, 2 Jul 2019 22:31:20 +0000 (15:31 -0700)
commit4905328cd34934be6f356e4a3bb719a81255ff3e
tree2e58130f3ed86d3847890a1421ee6ff053cb9760
parent3eb59a458902b61372f2c3d9a73345f362045ef9
mlxsw: spectrum_ptp: Fix validation in mlxsw_sp1_ptp_packet_finish()

Before mlxsw_sp1_ptp_packet_finish() sends the packet back, it validates
whether the corresponding port is still valid. However the condition is
incorrect: when mlxsw_sp_port == NULL, the code dereferences the port to
compare it to skb->dev.

The condition needs to check whether the port is present and skb->dev still
refers to that port (or else is NULL). If that does not hold, bail out.
Add a pair of parentheses to fix the condition.

Fixes: 2b7ce76eb55c ("mlxsw: spectrum: PTP: Support timestamping on Spectrum-1")
Reported-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Petr Machata <petrm@mellanox.com>
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Reviewed-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlxsw/spectrum_ptp.c