diff mbox series

[next] sfc: fix dereference of table before it is null checked

Message ID 20200512171355.221810-1-colin.king@canonical.com
State Accepted
Delegated to: David Miller
Headers show
Series [next] sfc: fix dereference of table before it is null checked | expand

Commit Message

Colin Ian King May 12, 2020, 5:13 p.m. UTC
From: Colin Ian King <colin.king@canonical.com>

Currently pointer table is being dereferenced on a null check of
table->must_restore_filters before it is being null checked, leading
to a potential null pointer dereference issue.  Fix this by null
checking table before dereferencing it when checking for a null
table->must_restore_filters.

Addresses-Coverity: ("Dereference before null check")
Fixes: e4fe938cff04 ("sfc: move 'must restore' flags out of ef10-specific nic_data")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/net/ethernet/sfc/mcdi_filters.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

Comments

Edward Cree May 13, 2020, 9:39 a.m. UTC | #1
On 12/05/2020 18:13, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Currently pointer table is being dereferenced on a null check of
> table->must_restore_filters before it is being null checked, leading
> to a potential null pointer dereference issue.  Fix this by null
> checking table before dereferencing it when checking for a null
> table->must_restore_filters.
>
> Addresses-Coverity: ("Dereference before null check")
> Fixes: e4fe938cff04 ("sfc: move 'must restore' flags out of ef10-specific nic_data")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
Acked-by: Edward Cree <ecree@solarflare.com>
David Miller May 13, 2020, 10:20 p.m. UTC | #2
From: Colin King <colin.king@canonical.com>
Date: Tue, 12 May 2020 18:13:55 +0100

> From: Colin Ian King <colin.king@canonical.com>
> 
> Currently pointer table is being dereferenced on a null check of
> table->must_restore_filters before it is being null checked, leading
> to a potential null pointer dereference issue.  Fix this by null
> checking table before dereferencing it when checking for a null
> table->must_restore_filters.
> 
> Addresses-Coverity: ("Dereference before null check")
> Fixes: e4fe938cff04 ("sfc: move 'must restore' flags out of ef10-specific nic_data")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>

Applied, thanks.
diff mbox series

Patch

diff --git a/drivers/net/ethernet/sfc/mcdi_filters.c b/drivers/net/ethernet/sfc/mcdi_filters.c
index 88de95a8c08c..455a62814fb9 100644
--- a/drivers/net/ethernet/sfc/mcdi_filters.c
+++ b/drivers/net/ethernet/sfc/mcdi_filters.c
@@ -1369,10 +1369,7 @@  void efx_mcdi_filter_table_restore(struct efx_nic *efx)
 
 	WARN_ON(!rwsem_is_locked(&efx->filter_sem));
 
-	if (!table->must_restore_filters)
-		return;
-
-	if (!table)
+	if (!table || !table->must_restore_filters)
 		return;
 
 	down_write(&table->lock);