dma: imx-dma: fix signedness bug
Subsystems (3)
PATCH 1/1 dma: imx-dma: fix signedness bug
mxdmac->channel was unsigned, so check (imxdmac->channel < 0) for failed imx_dma_request_by_prio() made no sence. Explicitly check signed values.
--- drivers/dma/imx-dma.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/dma/imx-dma.c +1 -1
@@ -335,7 +335,7 @@ static int __init imxdma_probe(struct platform_device *pdev) imxdmac->imxdma_channel =imx_dma_request_by_prio ("dmaengine" ,DMA_PRIO_MEDIUM ); -if (imxdmac->channel <0 ) +if ((int )imxdmac->channel <0 ) goto err_init; imx_dma_setup_handlers(imxdmac->imxdma_channel,
Signature · 1 line
1.7.0.4
Quoted 5 lines · Vasiliy Kulikov
mxdmac->channelwas unsigned, so check (imxdmac->channel< 0) for failedimx_dma_request_by_prio()made no sence. Explicitly check signed values.Signed-off-by Vasiliy Kulikov <[email protected]>
Quoted 21 lines
--- drivers/dma/imx-dma.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)drivers/dma/imx-dma.c +1
-1@@ -335,7 +335,7 @@ static int __init imxdma_probe(struct platform_device *pdev) imxdmac->imxdma_channel =imx_dma_request_by_prio ("dmaengine" ,DMA_PRIO_MEDIUM ); -if (imxdmac->channel <0 ) +if ((int )imxdmac->channel <0 ) goto err_init; imx_dma_setup_handlers(imxdmac->imxdma_channel,Signature · 1 line
1.7.0.4
Signature · 4 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
Quoted 14 lines · Vasiliy Kulikov
mxdmac->channelwas unsigned, so check (imxdmac->channel< 0) for failedimx_dma_request_by_prio()made no sence. Explicitly check signed values.Signed-off-by Vasiliy Kulikov <[email protected]>---
drivers/dma/imx-dma.c | 2 +-1 files changed, 1 insertions(+), 1 deletions(-)drivers/dma/imx-dma.c +0
-0
drivers/dma/imx-dma.c static int __init imxdma_probe(struct platform_device *pdev) · line 339
Quoted 6 lines
drivers/dma/imx-dma.c +1
-1@@ -335,7 +335,7 @@ static int __init imxdma_probe(struct platform_device *pdev) imxdmac->imxdma_channel = imx_dma_request_by_prio("dmaengine", DMA_PRIO_MEDIUM); - if (imxdmac->channel < 0) + if ((int)imxdmac->channel < 0) goto err_init;
Should this be:
if ((int)imxdmac->channel < 0) {
ret = -ENODEV;
goto err_init;
}...because I get the following in my compilation tests. drivers/dma/imx-dma.c: In function 'imxdma_probe':drivers/dma/imx-dma.c:324: warning: 'ret' may be used uninitialized in this function
--
Dan
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Sascha Hauer
maintainerQuoted 24 lines · Dan Williams
Quoted 14 lines · Vasiliy Kulikov
mxdmac->channelwas unsigned, so check (imxdmac->channel< 0) for failedimx_dma_request_by_prio()made no sence. Explicitly check signed values.Signed-off-by Vasiliy Kulikov <[email protected]>---
drivers/dma/imx-dma.c | 2 +-1 files changed, 1 insertions(+), 1 deletions(-)drivers/dma/imx-dma.c +0
-0drivers/dma/imx-dma.c static int __init imxdma_probe(struct platform_device *pdev) · line 339
Quoted 6 lines
drivers/dma/imx-dma.c +1
-1@@ -335,7 +335,7 @@ static int __init imxdma_probe(struct platform_device *pdev) imxdmac->imxdma_channel = imx_dma_request_by_prio("dmaengine", DMA_PRIO_MEDIUM); - if (imxdmac->channel < 0) + if ((int)imxdmac->channel < 0) goto err_init;Should this be:
Quoted 6 lines
if ((int)imxdmac->channel < 0) { ret = -ENODEV; goto err_init; }...because I get the following in my compilation tests.
Yes, ret is clearly used uninitialized. I wonder why my gcc-4.3.2 compiler does not warn me about this :(
Sascha
Signature · 8 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | -- To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Sascha Hauer
maintainermxdmac->channel was unsigned, so check (imxdmac->channel < 0) for failed imx_dma_request_by_prio() made no sence. Explicitly check signed values.
Also, fix uninitialzed use of ret.
---
Here's an updated patch fixing both issues.
drivers/dma/imx-dma.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)
drivers/dma/imx-dma.c +3 -1
@@ -335,8 +335,10 @@ static int __init imxdma_probe(struct platform_device *pdev) imxdmac->imxdma_channel =imx_dma_request_by_prio ("dmaengine" ,DMA_PRIO_MEDIUM ); -if (imxdmac->channel <0 ) +if ((int )imxdmac->channel <0 ) { + ret = -ENODEV ; goto err_init; + }imx_dma_setup_handlers (imxdmac->imxdma_channel, imxdma_irq_handler, imxdma_err_handler, imxdmac);
Signature · 7 lines
1.7.2.3 -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |