diff mbox series

[net-next,2/2] ionic: prevent early watchdog check

Message ID 20200929221956.3521-3-snelson@pensando.io
State Superseded
Headers show
Series ionic watchdog training | expand

Commit Message

Shannon Nelson Sept. 29, 2020, 10:19 p.m. UTC
In one corner case scenario, the driver device lif setup can
get delayed such that the ionic_watchdog_cb() timer goes off
before the ionic->lif is set, thus causing a NULL pointer panic.
We catch the problem by checking for a NULL lif just a little
earlier in the callback.

Signed-off-by: Shannon Nelson <snelson@pensando.io>
---
 drivers/net/ethernet/pensando/ionic/ionic_dev.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Jakub Kicinski Sept. 30, 2020, 12:15 a.m. UTC | #1
On Tue, 29 Sep 2020 15:19:56 -0700 Shannon Nelson wrote:
> In one corner case scenario, the driver device lif setup can
> get delayed such that the ionic_watchdog_cb() timer goes off
> before the ionic->lif is set, thus causing a NULL pointer panic.
> We catch the problem by checking for a NULL lif just a little
> earlier in the callback.
> 
> Signed-off-by: Shannon Nelson <snelson@pensando.io>

Hah, I should have looked at the second patch :D
Shannon Nelson Sept. 30, 2020, 12:17 a.m. UTC | #2
On 9/29/20 5:15 PM, Jakub Kicinski wrote:
> On Tue, 29 Sep 2020 15:19:56 -0700 Shannon Nelson wrote:
>> In one corner case scenario, the driver device lif setup can
>> get delayed such that the ionic_watchdog_cb() timer goes off
>> before the ionic->lif is set, thus causing a NULL pointer panic.
>> We catch the problem by checking for a NULL lif just a little
>> earlier in the callback.
>>
>> Signed-off-by: Shannon Nelson <snelson@pensando.io>
> Hah, I should have looked at the second patch :D

Am I making my patches too small now?  :-)

sln
Jakub Kicinski Sept. 30, 2020, 12:26 a.m. UTC | #3
On Tue, 29 Sep 2020 17:17:45 -0700 Shannon Nelson wrote:
> On 9/29/20 5:15 PM, Jakub Kicinski wrote:
> > On Tue, 29 Sep 2020 15:19:56 -0700 Shannon Nelson wrote:  
> >> In one corner case scenario, the driver device lif setup can
> >> get delayed such that the ionic_watchdog_cb() timer goes off
> >> before the ionic->lif is set, thus causing a NULL pointer panic.
> >> We catch the problem by checking for a NULL lif just a little
> >> earlier in the callback.
> >>
> >> Signed-off-by: Shannon Nelson <snelson@pensando.io>  
> > Hah, I should have looked at the second patch :D  
> 
> Am I making my patches too small now?  :-)

Just right :)
diff mbox series

Patch

diff --git a/drivers/net/ethernet/pensando/ionic/ionic_dev.c b/drivers/net/ethernet/pensando/ionic/ionic_dev.c
index 306e9401b09b..f90322ec3e18 100644
--- a/drivers/net/ethernet/pensando/ionic/ionic_dev.c
+++ b/drivers/net/ethernet/pensando/ionic/ionic_dev.c
@@ -19,9 +19,12 @@  static void ionic_watchdog_cb(struct timer_list *t)
 	mod_timer(&ionic->watchdog_timer,
 		  round_jiffies(jiffies + ionic->watchdog_period));
 
+	if (!ionic->lif)
+		return;
+
 	hb = ionic_heartbeat_check(ionic);
 
-	if (hb >= 0 && ionic->lif)
+	if (hb >= 0)
 		ionic_link_status_check_request(ionic->lif);
 }