From: Adrien Grassein <adrien.grassein@gmail.com>
Cc: dri-devel@lists.freedesktop.org, dan.carpenter@oracle.com,
Adrien Grassein <adrien.grassein@gmail.com>
Subject: [PATCH v4 1/1] drm/bridge: lt8912b: Fix issues found during static analysis
Date: Wed, 31 Mar 2021 13:49:19 +0200 [thread overview]
Message-ID: <20210331114919.370053-2-adrien.grassein@gmail.com> (raw)
In-Reply-To: <20210331114919.370053-1-adrien.grassein@gmail.com>
Some issues where found during static analysis of this driver.
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Suggested-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Adrien Grassein <adrien.grassein@gmail.com>
---
drivers/gpu/drm/bridge/lontium-lt8912b.c | 27 +++++++++++++++---------
1 file changed, 17 insertions(+), 10 deletions(-)
diff --git a/drivers/gpu/drm/bridge/lontium-lt8912b.c b/drivers/gpu/drm/bridge/lontium-lt8912b.c
index 61491615bad0..4c8d79142262 100644
--- a/drivers/gpu/drm/bridge/lontium-lt8912b.c
+++ b/drivers/gpu/drm/bridge/lontium-lt8912b.c
@@ -621,7 +621,8 @@ static int lt8912_parse_dt(struct lt8912 *lt)
{
struct gpio_desc *gp_reset;
struct device *dev = lt->dev;
- int ret = 0;
+ int ret;
+ int data_lanes;
struct device_node *port_node;
struct device_node *endpoint;
@@ -635,13 +636,16 @@ static int lt8912_parse_dt(struct lt8912 *lt)
lt->gp_reset = gp_reset;
endpoint = of_graph_get_endpoint_by_regs(dev->of_node, 0, -1);
- if (IS_ERR(endpoint)) {
- ret = PTR_ERR(endpoint);
- goto end;
- }
+ if (!endpoint)
+ return -ENODEV;
- lt->data_lanes = of_property_count_u32_elems(endpoint, "data-lanes");
+ data_lanes = of_property_count_u32_elems(endpoint, "data-lanes");
of_node_put(endpoint);
+ if (data_lanes < 0) {
+ dev_err(lt->dev, "%s: Bad data-lanes property\n", __func__);
+ return data_lanes;
+ }
+ lt->data_lanes = data_lanes;
lt->host_node = of_graph_get_remote_node(dev->of_node, 0, -1);
if (!lt->host_node) {
@@ -658,19 +662,22 @@ static int lt8912_parse_dt(struct lt8912 *lt)
}
lt->hdmi_port = of_drm_find_bridge(port_node);
- if (IS_ERR(lt->hdmi_port)) {
+ if (!lt->hdmi_port) {
dev_err(lt->dev, "%s: Failed to get hdmi port\n", __func__);
- ret = PTR_ERR(lt->hdmi_port);
- of_node_put(lt->host_node);
- goto end;
+ ret = -ENODEV;
+ of_node_put(port_node);
+ goto err_free_host_node;
}
if (!of_device_is_compatible(port_node, "hdmi-connector")) {
dev_err(lt->dev, "%s: Failed to get hdmi port\n", __func__);
+ of_node_put(port_node);
ret = -EINVAL;
+ goto err_free_host_node;
}
of_node_put(port_node);
+ return 0;
end:
return ret;
--
2.25.1
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2021-03-31 11:49 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-31 11:49 [PATCH v4 0/1] Fixes 30e2ae943c26 "drm/bridge: Introduce LT8912B DSI to HDMI" Adrien Grassein
2021-03-31 11:49 ` Adrien Grassein [this message]
2021-03-31 12:14 ` [PATCH v4 1/1] drm/bridge: lt8912b: Fix issues found during static analysis Dan Carpenter
2021-03-31 12:57 ` Andrzej Hajda
2021-03-31 14:39 ` Dan Carpenter
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=20210331114919.370053-2-adrien.grassein@gmail.com \
--to=adrien.grassein@gmail.com \
--cc=dan.carpenter@oracle.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox