Skip to contentSkip to conversation

mailbox: bcm-pdc: potential NULL dereference in pdc_shutdown()

PATCH In review Dan Carpenter 2 participants 2 messages Aug 4, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mailbox: bcm-pdc: potential NULL dereference in pdc_shutdown()

We can't pass NULL pointers to pdc_ring_free() so I moved the check for NULL.

drivers/mailbox/bcm-pdc-mailbox.c +4 -3
index cbe0c1e..c56d4d0 100644
@@ -1191,10 +1191,11 @@ static void pdc_shutdown(struct mbox_chan *chan)
 {
 	struct pdc_state *pdcs = chan->con_priv;
 
-	if (pdcs)
-		dev_dbg(&pdcs->pdev->dev,
-			"Shutdown mailbox channel for PDC %u", pdcs->pdc_idx);
+	if (!pdcs)
+		return;
 
+	dev_dbg(&pdcs->pdev->dev,
+		"Shutdown mailbox channel for PDC %u", pdcs->pdc_idx);
 	pdc_ring_free(pdcs);
 }
 
#1 lore raw

Dan,

The fix looks good to me. Thanks for finding and fixing.

Rob

Quoted 24 lines · Dan Carpenter

We can't pass NULL pointers to pdc_ring_free() so I moved the check for NULL.

drivers/mailbox/bcm-pdc-mailbox.c +4 -3
index cbe0c1e..c56d4d0 100644
@@ -1191,10 +1191,11 @@ static void pdc_shutdown(struct mbox_chan *chan)
  {
  	struct pdc_state *pdcs = chan->con_priv;
 
-	if (pdcs)
-		dev_dbg(&pdcs->pdev->dev,
-			"Shutdown mailbox channel for PDC %u", pdcs->pdc_idx);
+	if (!pdcs)
+		return;
 
+	dev_dbg(&pdcs->pdev->dev,
+		"Shutdown mailbox channel for PDC %u", pdcs->pdc_idx);
  	pdc_ring_free(pdcs);
  }