[bug report] drm/bridge: Introduce LT8912B DSI to HDMI bridge
Dan Carpenter
dan.carpenter at oracle.com
Wed Mar 31 08:12:38 UTC 2021
Hello Adrien Grassein,
The patch 30e2ae943c26: "drm/bridge: Introduce LT8912B DSI to HDMI
bridge" from Mar 26, 2021, leads to the following static checker
warning:
drivers/gpu/drm/bridge/lontium-lt8912b.c:638 lt8912_parse_dt()
warn: 'endpoint' isn't an ERR_PTR
drivers/gpu/drm/bridge/lontium-lt8912b.c
620 static int lt8912_parse_dt(struct lt8912 *lt)
621 {
622 struct gpio_desc *gp_reset;
623 struct device *dev = lt->dev;
624 int ret = 0;
625 struct device_node *port_node;
626 struct device_node *endpoint;
627
628 gp_reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);
629 if (IS_ERR(gp_reset)) {
630 ret = PTR_ERR(gp_reset);
631 if (ret != -EPROBE_DEFER)
632 dev_err(dev, "Failed to get reset gpio: %d\n", ret);
633 return ret;
634 }
635 lt->gp_reset = gp_reset;
636
637 endpoint = of_graph_get_endpoint_by_regs(dev->of_node, 0, -1);
638 if (IS_ERR(endpoint)) {
Endpoint isn't an error pointer. You could just delete this check if
you wanted and check of_property_count_u32_elems() for errors.
639 ret = PTR_ERR(endpoint);
640 goto end;
goto end is a do nothing goto. Genereally direct returns are more
readable have fewer bugs (based on ten years of reviewing static
analysis warnings).
641 }
642
643 lt->data_lanes = of_property_count_u32_elems(endpoint, "data-lanes");
Either way, it's probably a good idea to check if
of_property_count_u32_elems() fails.
644 of_node_put(endpoint);
645
646 lt->host_node = of_graph_get_remote_node(dev->of_node, 0, -1);
647 if (!lt->host_node) {
648 dev_err(lt->dev, "%s: Failed to get remote port\n", __func__);
649 ret = -ENODEV;
650 goto end;
651 }
652
653 port_node = of_graph_get_remote_node(dev->of_node, 1, -1);
654 if (!port_node) {
655 dev_err(lt->dev, "%s: Failed to get connector port\n", __func__);
656 ret = -ENODEV;
657 goto err_free_host_node;
658 }
659
660 lt->hdmi_port = of_drm_find_bridge(port_node);
661 if (IS_ERR(lt->hdmi_port)) {
662 dev_err(lt->dev, "%s: Failed to get hdmi port\n", __func__);
663 ret = PTR_ERR(lt->hdmi_port);
664 of_node_put(lt->host_node);
665 goto end;
This should call of_node_put(port_node); then goto err_free_host_node;
666 }
667
668 if (!of_device_is_compatible(port_node, "hdmi-connector")) {
669 dev_err(lt->dev, "%s: Failed to get hdmi port\n", __func__);
670 ret = -EINVAL;
This should call of_node_put(port_node); then goto err_free_host_node;
as well.
671 }
672
673 of_node_put(port_node);
674
675 end:
676 return ret;
677
678 err_free_host_node:
679 of_node_put(lt->host_node);
680 return ret;
681 }
regards,
dan carpenter
More information about the dri-devel
mailing list