All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: adrien.grassein@gmail.com
Cc: dri-devel@lists.freedesktop.org
Subject: [bug report] drm/bridge: Introduce LT8912B DSI to HDMI bridge
Date: Wed, 31 Mar 2021 11:12:38 +0300	[thread overview]
Message-ID: <YGQu9uZ/d5ph+eS9@mwanda> (raw)

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
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

             reply	other threads:[~2021-03-31  8:12 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-31  8:12 Dan Carpenter [this message]
2021-03-31  8:14 ` [bug report] drm/bridge: Introduce LT8912B DSI to HDMI bridge Dan Carpenter
2021-03-31  9:17   ` Adrien Grassein
2021-03-31  9:27     ` Dan Carpenter
2021-03-31  9:29       ` Adrien Grassein

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YGQu9uZ/d5ph+eS9@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=adrien.grassein@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.