From: Edward Cree <ecree@solarflare.com>
To: <netdev@vger.kernel.org>
Cc: Shradha Shah <sshah@solarflare.com>
Subject: [PATCH net] sfc: check for NULL efx->ptp_data in efx_ptp_event
Date: Mon, 24 Feb 2014 19:39:57 +0000 [thread overview]
Message-ID: <530BA00D.8000109@solarflare.com> (raw)
If we receive a PTP event from the NIC when we haven't set up PTP state
in the driver, we attempt to read through a NULL pointer efx->ptp_data,
triggering a panic.
Signed-off-by: Edward Cree <ecree@solarflare.com>
---
While this shouldn't happen with existing released firmware, future
sfn7322f firmware is planned to enable PPS irrespective of whether
timestamping (and thus PTP) is enabled. We are considering workarounds,
but this defensive patch seemed like a good idea anyway in case the
firmware gets in a muddle.
Also, in principle this shouldn't happen on 3.14+ kernels as the driver
should always set up PTP state at probe time (though there might still
be a race against the firmware sending its first PPS), however 3.12 and
3.13 both supported EF10 but not PTP-on-EF10 and thus they never set up
the PTP state; hence this fix should also be backported to those series.
--- linux-3.13/drivers/net/ethernet/sfc/ptp.c.orig 2014-01-20
02:40:07.000000000 +0000
+++ linux-3.13/drivers/net/ethernet/sfc/ptp.c 2014-02-24
17:46:31.753497000 +0000
@@ -1360,6 +1360,13 @@ void efx_ptp_event(struct efx_nic *efx,
struct efx_ptp_data *ptp = efx->ptp_data;
int code = EFX_QWORD_FIELD(*ev, MCDI_EVENT_CODE);
+ if (!ptp) {
+ if (net_ratelimit())
+ netif_warn(efx, drv, efx->net_dev,
+ "Received PTP event but PTP not set up\n");
+ return;
+ }
+
if (!ptp->enabled)
return;
next reply other threads:[~2014-02-24 19:40 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-24 19:39 Edward Cree [this message]
2014-02-24 23:40 ` [PATCH net] sfc: check for NULL efx->ptp_data in efx_ptp_event Ben Hutchings
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=530BA00D.8000109@solarflare.com \
--to=ecree@solarflare.com \
--cc=netdev@vger.kernel.org \
--cc=sshah@solarflare.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).