]> git.baikalelectronics.ru Git - kernel.git/commit
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)
committerDavid S. Miller <davem@davemloft.net>
Tue, 7 Mar 2017 21:47:14 +0000 (13:47 -0800)
commit2336b03cbf042f7c09d2e7c166eb4a6f8502ef11
tree20b9e7dc51f65385a9000ade93bde03cd20c80a2
parent743997ef5c6fd991722d43490126d46839495435
bnx2x: prevent crash when accessing PTP with interface down

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>
drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c