Hello Linus Walleij,
The patch 5fc537bfd000: "drm/mcde: Add new driver for ST-Ericsson MCDE" from May 24, 2019, leads to the following static checker warning:
drivers/gpu/drm/mcde/mcde_drv.c:488 mcde_probe() error: uninitialized symbol 'match'.
drivers/gpu/drm/mcde/mcde_drv.c 470 writel(0xFFFFFFFF, mcde->regs + MCDE_RISERR); 471 472 /* Spawn child devices for the DSI ports */ 473 devm_of_platform_populate(dev); 474 475 /* Create something that will match the subdrivers when we bind */ 476 for (i = 0; i < ARRAY_SIZE(mcde_component_drivers); i++) { 477 struct device_driver *drv = &mcde_component_drivers[i]->driver; 478 struct device *p = NULL, *d; 479 480 while ((d = bus_find_device(&platform_bus_type, p, drv, 481 (void *)platform_bus_type.match))) { ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ The concern would be that this condintion is never met. I suspet that's not possible?
482 put_device(p); 483 component_match_add(dev, &match, mcde_compare_dev, d); 484 p = d; 485 } 486 put_device(p); 487 } 488 if (IS_ERR(match)) { 489 dev_err(dev, "could not create component match\n"); 490 ret = PTR_ERR(match); 491 goto clk_disable; 492 } 493 ret = component_master_add_with_match(&pdev->dev, &mcde_drm_comp_ops, 494 match); 495 if (ret) {
regards, dan carpenter
On Wed, May 29, 2019 at 1:32 PM Dan Carpenter dan.carpenter@oracle.com wrote:
drivers/gpu/drm/mcde/mcde_drv.c:488 mcde_probe() error: uninitialized symbol 'match'.
(...)
480 while ((d = bus_find_device(&platform_bus_type, p, drv, 481 (void *)platform_bus_type.match))) { ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ The concern would be that this condintion is never met. I suspet that's not possible?
Component drivers have this property, they rely on the subcomponents to be there for the functional whole to work. If it's not, all hell break loose in different ways. So at least one subcomponent (DSI in this case) needs to be found.
But it's fine to initialize match to NULL if it makes the static checks happier!
But that just masks the deeper problem, which I found in the qcom driver: component_master_add_with_match() can be called with match set to NULL, which it actually cannot handle. This is a generic problem in DRM and needs to be fixed everywhere.
I made a patch like this:
diff --git a/drivers/gpu/drm/mcde/mcde_drv.c b/drivers/gpu/drm/mcde/mcde_drv.c index baf63fb6850a..bc11c446e594 100644 --- a/drivers/gpu/drm/mcde/mcde_drv.c +++ b/drivers/gpu/drm/mcde/mcde_drv.c @@ -319,7 +319,7 @@ static int mcde_probe(struct platform_device *pdev) struct device *dev = &pdev->dev; struct drm_device *drm; struct mcde *mcde; - struct component_match *match; + struct component_match *match = NULL; struct resource *res; u32 pid; u32 val; @@ -485,7 +485,7 @@ static int mcde_probe(struct platform_device *pdev) } put_device(p); } - if (IS_ERR(match)) { + if (IS_ERR_OR_NULL(match)) { dev_err(dev, "could not create component match\n"); ret = PTR_ERR(match); goto clk_disable;
But I need to test that on real hardware before I submit it.
Thanks, Linus Walleij
dri-devel@lists.freedesktop.org