* re: mmc: omap: Fix DMA configuration to not rely on device id
@ 2013-12-02 8:06 Dan Carpenter
2013-12-02 19:05 ` Tony Lindgren
0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2013-12-02 8:06 UTC (permalink / raw)
To: tony; +Cc: linux-omap
Hello Tony Lindgren,
This is a semi-automatic email about new static checker warnings.
The patch 31ee9181eb92: "mmc: omap: Fix DMA configuration to not rely
on device id" from Nov 26, 2013, leads to the following Smatch
complaint:
drivers/mmc/host/omap.c:1468 mmc_omap_probe()
error: we previously assumed 'res' could be null (see line 1410)
drivers/mmc/host/omap.c
1409 res = platform_get_resource_byname(pdev, IORESOURCE_DMA, "rx");
1410 if (res)
^^^
Patch introduces a check.
1411 sig = res->start;
1412 host->dma_rx = dma_request_slave_channel_compat(mask,
1413 omap_dma_filter_fn, &sig, &pdev->dev, "rx");
1414 if (!host->dma_rx)
1415 dev_warn(host->dev, "unable to obtain RX DMA engine channel %u\n",
1416 sig);
1417
1418 ret = request_irq(host->irq, mmc_omap_irq, 0, DRIVER_NAME, host);
1419 if (ret)
1420 goto err_free_dma;
1421
1422 if (pdata->init != NULL) {
1423 ret = pdata->init(&pdev->dev);
1424 if (ret < 0)
1425 goto err_free_irq;
1426 }
1427
1428 host->nr_slots = pdata->nr_slots;
1429 host->reg_shift = (mmc_omap7xx() ? 1 : 2);
1430
1431 host->mmc_omap_wq = alloc_workqueue("mmc_omap", 0, 0);
1432 if (!host->mmc_omap_wq)
1433 goto err_plat_cleanup;
1434
1435 for (i = 0; i < pdata->nr_slots; i++) {
1436 ret = mmc_omap_new_slot(host, i);
1437 if (ret < 0) {
1438 while (--i >= 0)
1439 mmc_omap_remove_slot(host->slots[i]);
1440
1441 goto err_destroy_wq;
1442 }
1443 }
1444
1445 return 0;
1446
1447 err_destroy_wq:
1448 destroy_workqueue(host->mmc_omap_wq);
1449 err_plat_cleanup:
1450 if (pdata->cleanup)
1451 pdata->cleanup(&pdev->dev);
1452 err_free_irq:
1453 free_irq(host->irq, host);
1454 err_free_dma:
1455 if (host->dma_tx)
1456 dma_release_channel(host->dma_tx);
1457 if (host->dma_rx)
1458 dma_release_channel(host->dma_rx);
1459 clk_put(host->fclk);
1460 err_free_iclk:
1461 clk_disable(host->iclk);
1462 clk_put(host->iclk);
1463 err_free_mmc_host:
1464 iounmap(host->virt_base);
1465 err_ioremap:
1466 kfree(host);
1467 err_free_mem_region:
1468 release_mem_region(res->start, resource_size(res));
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Existing unchecked dereferences.
1469 return ret;
1470 }
regards,
dan carpenter
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: mmc: omap: Fix DMA configuration to not rely on device id
2013-12-02 8:06 mmc: omap: Fix DMA configuration to not rely on device id Dan Carpenter
@ 2013-12-02 19:05 ` Tony Lindgren
0 siblings, 0 replies; 2+ messages in thread
From: Tony Lindgren @ 2013-12-02 19:05 UTC (permalink / raw)
To: Dan Carpenter; +Cc: linux-omap
* Dan Carpenter <dan.carpenter@oracle.com> [131202 00:07]:
> Hello Tony Lindgren,
>
> This is a semi-automatic email about new static checker warnings.
>
> The patch 31ee9181eb92: "mmc: omap: Fix DMA configuration to not rely
> on device id" from Nov 26, 2013, leads to the following Smatch
> complaint:
>
> drivers/mmc/host/omap.c:1468 mmc_omap_probe()
> error: we previously assumed 'res' could be null (see line 1410)
>
> drivers/mmc/host/omap.c
> 1409 res = platform_get_resource_byname(pdev, IORESOURCE_DMA, "rx");
> 1410 if (res)
> ^^^
> Patch introduces a check.
>
> 1411 sig = res->start;
> 1412 host->dma_rx = dma_request_slave_channel_compat(mask,
> 1413 omap_dma_filter_fn, &sig, &pdev->dev, "rx");
> 1414 if (!host->dma_rx)
> 1415 dev_warn(host->dev, "unable to obtain RX DMA engine channel %u\n",
> 1416 sig);
> 1417
> 1418 ret = request_irq(host->irq, mmc_omap_irq, 0, DRIVER_NAME, host);
> 1419 if (ret)
> 1420 goto err_free_dma;
> 1421
> 1422 if (pdata->init != NULL) {
> 1423 ret = pdata->init(&pdev->dev);
> 1424 if (ret < 0)
> 1425 goto err_free_irq;
> 1426 }
> 1427
> 1428 host->nr_slots = pdata->nr_slots;
> 1429 host->reg_shift = (mmc_omap7xx() ? 1 : 2);
> 1430
> 1431 host->mmc_omap_wq = alloc_workqueue("mmc_omap", 0, 0);
> 1432 if (!host->mmc_omap_wq)
> 1433 goto err_plat_cleanup;
> 1434
> 1435 for (i = 0; i < pdata->nr_slots; i++) {
> 1436 ret = mmc_omap_new_slot(host, i);
> 1437 if (ret < 0) {
> 1438 while (--i >= 0)
> 1439 mmc_omap_remove_slot(host->slots[i]);
> 1440
> 1441 goto err_destroy_wq;
> 1442 }
> 1443 }
> 1444
> 1445 return 0;
> 1446
> 1447 err_destroy_wq:
> 1448 destroy_workqueue(host->mmc_omap_wq);
> 1449 err_plat_cleanup:
> 1450 if (pdata->cleanup)
> 1451 pdata->cleanup(&pdev->dev);
> 1452 err_free_irq:
> 1453 free_irq(host->irq, host);
> 1454 err_free_dma:
> 1455 if (host->dma_tx)
> 1456 dma_release_channel(host->dma_tx);
> 1457 if (host->dma_rx)
> 1458 dma_release_channel(host->dma_rx);
> 1459 clk_put(host->fclk);
> 1460 err_free_iclk:
> 1461 clk_disable(host->iclk);
> 1462 clk_put(host->iclk);
> 1463 err_free_mmc_host:
> 1464 iounmap(host->virt_base);
> 1465 err_ioremap:
> 1466 kfree(host);
> 1467 err_free_mem_region:
> 1468 release_mem_region(res->start, resource_size(res));
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> Existing unchecked dereferences.
>
> 1469 return ret;
> 1470 }
Oops. Thanks a lot for reporting this, I'll post a fix for it separately.
Looks like the minimal fix is to add what at least omap_hsmmc.c is doing:
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (res)
release_mem_region(res->start, resource_size(res));
Regards,
Tony
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-12-02 19:05 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-02 8:06 mmc: omap: Fix DMA configuration to not rely on device id Dan Carpenter
2013-12-02 19:05 ` Tony Lindgren
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).