[PATCH 1/3] UBUNTU: SAUCE: opennsl: bcm-knet: check for null sinfo to avoid a null pointer dereference

Colin King colin.king at canonical.com
Wed Sep 20 10:27:05 UTC 2017


From: Colin Ian King <colin.king at canonical.com>

BugLink: https://launchpad.net/bugs/1718388

sinfo can potentially be null, so add a null check to avoid a null
pointer deference on sinfo->info_id.

Detected by CoverityScan CID#1456902 ("Dereference before null check")

Signed-off-by: Colin Ian King <colin.king at canonical.com>
---
 .../systems/linux/kernel/modules/bcm-knet/bcm-knet.c                   | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/ubuntu/opennsl/OpenNSL/sdk-6.4.10-gpl-modules/systems/linux/kernel/modules/bcm-knet/bcm-knet.c b/ubuntu/opennsl/OpenNSL/sdk-6.4.10-gpl-modules/systems/linux/kernel/modules/bcm-knet/bcm-knet.c
index 9dc94b3..9aed5dc 100644
--- a/ubuntu/opennsl/OpenNSL/sdk-6.4.10-gpl-modules/systems/linux/kernel/modules/bcm-knet/bcm-knet.c
+++ b/ubuntu/opennsl/OpenNSL/sdk-6.4.10-gpl-modules/systems/linux/kernel/modules/bcm-knet/bcm-knet.c
@@ -5605,7 +5605,8 @@ bkn_get_next_dma_event(kcom_msg_dma_info_t *kmsg)
             sinfo = bkn_sinfo_from_unit(dev_no);
         }
 
-        if ((sinfo->inst_id != 0) && ((sinfo->inst_id & (1 << dev_evt)) == 0)){
+        if (sinfo && (sinfo->inst_id != 0) &&
+	    ((sinfo->inst_id & (1 << dev_evt)) == 0)) {
             DBG_INST((" %s skip dev(%d)\n",__FUNCTION__,dev_evt));
             continue;
         }
-- 
2.7.4





More information about the kernel-team mailing list