[rtems commit] grspw_pkt.c: Fix Dereference before null check ( CID #1399846)

Joel Sherrill joel at rtems.org
Fri Feb 19 20:06:08 UTC 2021


Module:    rtems
Branch:    master
Commit:    fac1ff18203b4fcb53610244b066a427f88faa3a
Changeset: http://git.rtems.org/rtems/commit/?id=fac1ff18203b4fcb53610244b066a427f88faa3a

Author:    Ryan Long <ryan.long at oarcorp.com>
Date:      Tue Feb 16 17:39:30 2021 -0500

grspw_pkt.c: Fix Dereference before null check (CID #1399846)

CID 1399846: Dereference before null check in grspw_addr_ctrl().

Closes #4253

---

 bsps/shared/grlib/spw/grspw_pkt.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/bsps/shared/grlib/spw/grspw_pkt.c b/bsps/shared/grlib/spw/grspw_pkt.c
index 2cc4e886..ca8767e 100644
--- a/bsps/shared/grlib/spw/grspw_pkt.c
+++ b/bsps/shared/grlib/spw/grspw_pkt.c
@@ -655,7 +655,7 @@ void grspw_hw_support(void *d, struct grspw_hw_sup *hw)
 void grspw_addr_ctrl(void *d, struct grspw_addr_config *cfg)
 {
 	struct grspw_priv *priv = d;
-	struct grspw_regs *regs = priv->regs;
+	struct grspw_regs *regs;
 	unsigned int ctrl, nodeaddr;
 	SPIN_IRQFLAGS(irqflags);
 	int i;
@@ -663,6 +663,8 @@ void grspw_addr_ctrl(void *d, struct grspw_addr_config *cfg)
 	if (!priv || !cfg)
 		return;
 
+        regs = priv->regs;
+
 	SPIN_LOCK_IRQ(&priv->devlock, irqflags);
 
 	if (cfg->promiscuous != -1) {



More information about the vc mailing list