Skip to contentSkip to conversation

dma: mv_xor: error handling fix in mv_xor_channel_add()

PATCH New Dan Carpenter 1 participant 1 message Aug 22, 2013

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

PATCH 1/1 dma: mv_xor: error handling fix in mv_xor_channel_add()

We haven't allocated the dma buffer at this point and also if we "goto err_free_dma;" then it leads to a NULL dereference. Just return directly.

---
I can't compile this file.

drivers/dma/mv_xor.c +2 -4
index d9a2677..0e9e835 100644
@@ -1029,10 +1029,8 @@ mv_xor_channel_add(struct mv_xor_device *xordev,
 	struct dma_device *dma_dev;
 
 	mv_chan = devm_kzalloc(&pdev->dev, sizeof(*mv_chan), GFP_KERNEL);
-	if (!mv_chan) {
-		ret = -ENOMEM;
-		goto err_free_dma;
-	}
+	if (!mv_chan)
+		return ERR_PTR(-ENOMEM);
 
 	mv_chan->idx = idx;
 	mv_chan->irq = irq;