Re: drivers/media/platform/nxp/dw100/dw100.c:1574 dw100_probe() warn: missing unwind goto?

From: Xavier Roumegue (OSS)
Date: Tue Jan 03 2023 - 05:56:42 EST


Hi Dan,

On 1/3/23 09:13, Dan Carpenter wrote:
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 69b41ac87e4a664de78a395ff97166f0b2943210
commit: cb6d000fcaa6e2ee0e01937364c686690329bf5e media: dw100: Add i.MX8MP dw100 dewarper driver
config: ia64-randconfig-m041-20230101
compiler: ia64-linux-gcc (GCC) 12.1.0

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@xxxxxxxxx>
| Reported-by: Dan Carpenter <error27@xxxxxxxxx>

smatch warnings:
drivers/media/platform/nxp/dw100/dw100.c:1574 dw100_probe() warn: missing unwind goto?

vim +1574 drivers/media/platform/nxp/dw100/dw100.c

cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1531 static int dw100_probe(struct platform_device *pdev)
cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1532 {
cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1533 struct dw100_device *dw_dev;
cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1534 struct video_device *vfd;
cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1535 struct resource *res;
cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1536 int ret, irq;
cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1537
cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1538 dw_dev = devm_kzalloc(&pdev->dev, sizeof(*dw_dev), GFP_KERNEL);
cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1539 if (!dw_dev)
cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1540 return -ENOMEM;
cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1541 dw_dev->pdev = pdev;
cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1542
cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1543 ret = devm_clk_bulk_get_all(&pdev->dev, &dw_dev->clks);
cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1544 if (ret < 0) {
cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1545 dev_err(&pdev->dev, "Unable to get clocks: %d\n", ret);
cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1546 return ret;
cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1547 }
cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1548 dw_dev->num_clks = ret;
cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1549
cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1550 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1551 dw_dev->mmio = devm_ioremap_resource(&pdev->dev, res);
cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1552 if (IS_ERR(dw_dev->mmio))
cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1553 return PTR_ERR(dw_dev->mmio);
cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1554
cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1555 irq = platform_get_irq(pdev, 0);
cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1556 if (irq < 0)
cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1557 return irq;
cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1558
cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1559 platform_set_drvdata(pdev, dw_dev);
cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1560
cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1561 pm_runtime_enable(&pdev->dev);
cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1562 ret = pm_runtime_resume_and_get(&pdev->dev);
cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1563 if (ret < 0) {
cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1564 dev_err(&pdev->dev, "Unable to resume the device: %d\n", ret);
cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1565 goto err_pm;
cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1566 }
cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1567
cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1568 pm_runtime_put_sync(&pdev->dev);
cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1569
cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1570 ret = devm_request_irq(&pdev->dev, irq, dw100_irq_handler, IRQF_ONESHOT,
cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1571 dev_name(&pdev->dev), dw_dev);
cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1572 if (ret < 0) {
cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1573 dev_err(&pdev->dev, "Failed to request irq: %d\n", ret);
cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 @1574 return ret;

goto err_pm;
Indeed, this goto is missing. Thanks.
Regards,
Xavier

cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1575 }
cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1576
cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1577 ret = v4l2_device_register(&pdev->dev, &dw_dev->v4l2_dev);
cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1578 if (ret)
cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1579 goto err_pm;
cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1580
cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1581 vfd = dw100_init_video_device(dw_dev);
cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1582
cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1583 dw_dev->m2m_dev = v4l2_m2m_init(&dw100_m2m_ops);
cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1584 if (IS_ERR(dw_dev->m2m_dev)) {
cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1585 dev_err(&pdev->dev, "Failed to init mem2mem device\n");
cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1586 ret = PTR_ERR(dw_dev->m2m_dev);
cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1587 goto err_v4l2;
cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1588 }
cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1589
cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1590 dw_dev->mdev.dev = &pdev->dev;
cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1591 strscpy(dw_dev->mdev.model, "dw100", sizeof(dw_dev->mdev.model));
cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1592 media_device_init(&dw_dev->mdev);
cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1593 dw_dev->v4l2_dev.mdev = &dw_dev->mdev;
cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1594
cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1595 ret = video_register_device(vfd, VFL_TYPE_VIDEO, -1);
cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1596 if (ret) {
cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1597 dev_err(&pdev->dev, "Failed to register video device\n");
cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1598 goto err_m2m;
cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1599 }
cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1600
cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1601 ret = v4l2_m2m_register_media_controller(dw_dev->m2m_dev, vfd,
cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1602 MEDIA_ENT_F_PROC_VIDEO_SCALER);
cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1603 if (ret) {
cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1604 dev_err(&pdev->dev, "Failed to init mem2mem media controller\n");
cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1605 goto error_v4l2;
cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1606 }
cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1607
cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1608 ret = media_device_register(&dw_dev->mdev);
cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1609 if (ret) {
cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1610 dev_err(&pdev->dev, "Failed to register mem2mem media device\n");
cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1611 goto error_m2m_mc;
cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1612 }
cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1613
cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1614 dw100_debugfs_init(dw_dev);
cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1615
cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1616 dev_info(&pdev->dev,
cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1617 "dw100 v4l2 m2m registered as /dev/video%u\n", vfd->num);
cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1618
cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1619 return 0;
cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1620
cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1621 error_m2m_mc:
cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1622 v4l2_m2m_unregister_media_controller(dw_dev->m2m_dev);
cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1623 error_v4l2:
cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1624 video_unregister_device(vfd);
cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1625 err_m2m:
cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1626 v4l2_m2m_release(dw_dev->m2m_dev);
cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1627 err_v4l2:
cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1628 v4l2_device_unregister(&dw_dev->v4l2_dev);
cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1629 err_pm:
cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1630 pm_runtime_disable(&pdev->dev);
cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1631
cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1632 return ret;
cb6d000fcaa6e2 Xavier Roumegue 2022-07-30 1633 }