[bug report] drm/tve200: Clean up panel bridging

Dan Carpenter dan.carpenter at oracle.com
Fri Apr 1 10:07:05 UTC 2022


[ Old code... ]

Hello Linus Walleij,

The patch 9ab12e88a0b4: "drm/tve200: Clean up panel bridging" from
Sep 11, 2017, leads to the following Smatch static checker warning:

	drivers/gpu/drm/tve200/tve200_drv.c:96 tve200_modeset_init()
	warn: missing error code here? '_dev_err()' failed. 'ret' = '0'

drivers/gpu/drm/tve200/tve200_drv.c
    62 static int tve200_modeset_init(struct drm_device *dev)
    63 {
    64         struct drm_mode_config *mode_config;
    65         struct tve200_drm_dev_private *priv = dev->dev_private;
    66         struct drm_panel *panel;
    67         struct drm_bridge *bridge;
    68         int ret = 0;
    69 
    70         drm_mode_config_init(dev);
    71         mode_config = &dev->mode_config;
    72         mode_config->funcs = &mode_config_funcs;
    73         mode_config->min_width = 352;
    74         mode_config->max_width = 720;
    75         mode_config->min_height = 240;
    76         mode_config->max_height = 576;
    77 
    78         ret = drm_of_find_panel_or_bridge(dev->dev->of_node,
    79                                           0, 0, &panel, &bridge);
    80         if (ret && ret != -ENODEV)
    81                 return ret;

There is a return check here.

    82         if (panel) {
    83                 bridge = drm_panel_bridge_add_typed(panel,
    84                                                     DRM_MODE_CONNECTOR_Unknown);
    85                 if (IS_ERR(bridge)) {
    86                         ret = PTR_ERR(bridge);
    87                         goto out_bridge;
    88                 }
    89         } else {
    90                 /*
    91                  * TODO: when we are using a different bridge than a panel
    92                  * (such as a dumb VGA connector) we need to devise a different
    93                  * method to get the connector out of the bridge.
    94                  */
    95                 dev_err(dev->dev, "the bridge is not a panel\n");
--> 96                 goto out_bridge;

>From reading this code without looking deeply into the context it looks
like ret can be either 0 or -ENODEV.  Smatch does cross function
analysis (sometimes badly) and says that drm_of_find_panel_or_bridge()
only returns -EINVAL, zero, and -EPROBE_DEFER so it must be zero here.

    97         }
    98 
    99         ret = tve200_display_init(dev);
    100         if (ret) {
    101                 dev_err(dev->dev, "failed to init display\n");
    102                 goto out_bridge;
    103         }
    104 
    105         ret = drm_simple_display_pipe_attach_bridge(&priv->pipe,
    106                                                     bridge);
    107         if (ret) {
    108                 dev_err(dev->dev, "failed to attach bridge\n");
    109                 goto out_bridge;
    110         }
    111 
    112         priv->panel = panel;
    113         priv->connector = drm_panel_bridge_connector(bridge);
    114         priv->bridge = bridge;
    115 
    116         dev_info(dev->dev, "attached to panel %s\n",
    117                  dev_name(panel->dev));
    118 
    119         ret = drm_vblank_init(dev, 1);
    120         if (ret) {
    121                 dev_err(dev->dev, "failed to init vblank\n");
    122                 goto out_bridge;
    123         }
    124 
    125         drm_mode_config_reset(dev);
    126         drm_kms_helper_poll_init(dev);
    127 
    128         goto finish;
    129 
    130 out_bridge:
    131         if (panel)
    132                 drm_panel_bridge_remove(bridge);
    133         drm_mode_config_cleanup(dev);
    134 finish:
    135         return ret;
    136 }

regards,
dan carpenter


More information about the dri-devel mailing list