[lvc-project] [PATCH net] liquidio: check other_oct before dereferencing

Alexey V. Vissarionov gremlin at altlinux.org
Wed Apr 30 00:00:00 MSK 2025


get_other_octeon_device() may return NULL; avoid dereferencing the
other_oct pointer in that case.

Found by ALT Linux Team (altlinux.org) and Linux Verification Center
(linuxtesting.org).

Fixes: bb54be589c7a ("liquidio: fix Octeon core watchdog timeout false alarm")
Signed-off-by: Alexey V. Vissarionov <gremlin at altlinux.org>
---
 drivers/net/ethernet/cavium/liquidio/lio_main.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/cavium/liquidio/lio_main.c b/drivers/net/ethernet/cavium/liquidio/lio_main.c
index 1d79f6eaa41f6cbf..7b255126289b9fcd 100644
--- a/drivers/net/ethernet/cavium/liquidio/lio_main.c
+++ b/drivers/net/ethernet/cavium/liquidio/lio_main.c
@@ -796,10 +796,11 @@ static int liquidio_watchdog(void *param)
 
 #ifdef CONFIG_MODULE_UNLOAD
 		vfs_mask1 = READ_ONCE(oct->sriov_info.vf_drv_loaded_mask);
-		vfs_mask2 = READ_ONCE(other_oct->sriov_info.vf_drv_loaded_mask);
-
-		vfs_referencing_pf  = hweight64(vfs_mask1);
-		vfs_referencing_pf += hweight64(vfs_mask2);
+		vfs_referencing_pf = hweight64(vfs_mask1);
+		if (other_oct) {
+			vfs_mask2 = READ_ONCE(other_oct->sriov_info.vf_drv_loaded_mask);
+			vfs_referencing_pf += hweight64(vfs_mask2);
+		}
 
 		refcount = module_refcount(THIS_MODULE);
 		if (refcount >= vfs_referencing_pf) {


-- 
Alexey V. Vissarionov
gremlin ПРИ altlinux ТЧК org; +vii-cmiii-ccxxix-lxxix-xlii
GPG: 0D92F19E1C0DC36E27F61A29CD17E2B43D879005 @ hkp://keys.gnupg.net



More information about the lvc-project mailing list