bnx2x: prevent crash when accessing PTP with interface down
authorMichal Schmidt <mschmidt@redhat.com>
Fri, 3 Mar 2017 16:08:28 +0000 (17:08 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 14 Dec 2017 08:28:20 +0000 (09:28 +0100)
commitae6b3452faf741c4127288c71d6edd0f23d6b0bb
tree40806c3b40a287d1aafa4f56b5658c14455d5ca4
parentc72c7f2442654d68d38d22cc5a36dd2644d2848b
bnx2x: prevent crash when accessing PTP with interface down

[ Upstream commit 466e8bf10ac104d96e1ea813e8126e11cb72ea20 ]

It is possible to crash the kernel by accessing a PTP device while its
associated bnx2x interface is down. Before the interface is brought up,
the timecounter is not initialized, so accessing it results in NULL
dereference.

Fix it by checking if the interface is up.

Use -ENETDOWN as the error code when the interface is down.
 -EFAULT in bnx2x_ptp_adjfreq() did not seem right.

Tested using phc_ctl get/set/adj/freq commands.

Signed-off-by: Michal Schmidt <mschmidt@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c