Skip to contentSkip to conversation

dmaengine: st_fdma: fix uninitialized variable access

PATCH Applied Arnd Bergmann 3 participants 3 messages Oct 19, 2016

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

PATCH 1/1 dmaengine: st_fdma: fix uninitialized variable access

The newly added st_fdma driver introduces a build warning for allmodconfig when we add '-Wmaybe-uninitialized':

drivers/dma/st_fdma.c: In function 'st_fdma_probe':
drivers/dma/st_fdma.c:777:5: error: 'ret' may be used uninitialized in this function [-Werror=maybe-uninitialized]

The warning is correct, though this can't happen in practice as the check is redundant (we don't get to this function if the pointer is NULL). Even if the function were called with a NULL of_node, the check is not needed because of_property_read_u32 can deal with a NULL argument by returning an error.

Removing the unnecessary code simplifies the function and avoids the condition that we get the warning for.

Fixes 6b4cd727eaf1 ("dmaengine: st_fdma: Add STMicroelectronics FDMA engine driver support")
---
 drivers/dma/st_fdma.c | 14 ++------------
 1 file changed, 2 insertions(+), 12 deletions(-)
drivers/dma/st_fdma.c +2 -12
index 515e1d4c43e8..232d3547a6a3 100644
@@ -720,21 +720,11 @@ static int st_fdma_parse_dt(struct platform_device *pdev,
 			const struct st_fdma_driverdata *drvdata,
 			struct st_fdma_dev *fdev)
 {
-	struct device_node *np = pdev->dev.of_node;
-	int ret;
-
-	if (!np)
-		goto err;
-
-	ret = of_property_read_u32(np, "dma-channels", &fdev->nr_channels);
-	if (ret)
-		goto err;
-
 	snprintf(fdev->fw_name, FW_NAME_SIZE, "fdma_%s_%d.elf",
 		drvdata->name, drvdata->id);
 
-err:
-	return ret;
+	return of_property_read_u32(pdev->dev.of_node, "dma-channels",
+				    &fdev->nr_channels);
 }
 #define FDMA_DMA_BUSWIDTHS	(BIT(DMA_SLAVE_BUSWIDTH_1_BYTE) | \
 				 BIT(DMA_SLAVE_BUSWIDTH_2_BYTES) | \
Signature · 1 line
2.9.0
Acked-by on v1 1/1
#1 lore raw

Hi Arnd,

Quoted 12 lines · Arnd Bergmann

The newly added st_fdma driver introduces a build warning for allmodconfig when we add '-Wmaybe-uninitialized':

drivers/dma/st_fdma.c: In function 'st_fdma_probe':
drivers/dma/st_fdma.c:777:5: error: 'ret' may be used uninitialized in this function [-Werror=maybe-uninitialized]

The warning is correct, though this can't happen in practice as the check is redundant (we don't get to this function if the pointer is NULL). Even if the function were called with a NULL of_node, the check is not needed because of_property_read_u32 can deal with a NULL argument by returning an error.

Quoted 6 lines

Removing the unnecessary code simplifies the function and avoids the condition that we get the warning for.

Fixes 6b4cd727eaf1 ("dmaengine: st_fdma: Add STMicroelectronics FDMA engine driver support")

---

regards,

Peter.

Applied
#2 lore raw
In reply to Arnd Bergmann
Quoted 6 lines · Arnd Bergmann

The newly added st_fdma driver introduces a build warning for allmodconfig when we add '-Wmaybe-uninitialized':

drivers/dma/st_fdma.c: In function 'st_fdma_probe':
drivers/dma/st_fdma.c:777:5: error: 'ret' may be used uninitialized in this function [-Werror=maybe-uninitialized]

Quoted 8 lines

The warning is correct, though this can't happen in practice as the check is redundant (we don't get to this function if the pointer is NULL). Even if the function were called with a NULL of_node, the check is not needed because of_property_read_u32 can deal with a NULL argument by returning an error.

Removing the unnecessary code simplifies the function and avoids the condition that we get the warning for.

Applied, thanks

Signature · 1 line
~Vinod