* [PATCH] drm/rockchip: Fix uninitialized use of ret
@ 2017-09-21 0:13 ` Sean Paul
0 siblings, 0 replies; 5+ messages in thread
From: Sean Paul @ 2017-09-21 0:13 UTC (permalink / raw)
To: dri-devel; +Cc: linux-rockchip, linux-arm-kernel
If there are no children for lvds, ret is used uninitialized. This patch
initializes ret and returns an error if the port has no children.
Fixes: 34cc0aa25456 ("drm/rockchip: Add support for Rockchip Soc LVDS")
Cc: Mark Yao <mark.yao@rock-chips.com>
Cc: Heiko Stuebner <heiko@sntech.de>
Cc: Sandy Huang <hjc@rock-chips.com>
Cc: dri-devel@lists.freedesktop.org
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-rockchip@lists.infradead.org
Signed-off-by: Sean Paul <seanpaul@chromium.org>
---
drivers/gpu/drm/rockchip/rockchip_lvds.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/rockchip/rockchip_lvds.c b/drivers/gpu/drm/rockchip/rockchip_lvds.c
index c5fbe533796c..0ce6205d8d80 100644
--- a/drivers/gpu/drm/rockchip/rockchip_lvds.c
+++ b/drivers/gpu/drm/rockchip/rockchip_lvds.c
@@ -346,7 +346,7 @@ static int rockchip_lvds_bind(struct device *dev, struct device *master,
struct drm_connector *connector;
struct device_node *remote = NULL;
struct device_node *port, *endpoint;
- int ret;
+ int ret = 0, child_count = 0;
const char *name;
u32 endpoint_id;
@@ -358,13 +358,18 @@ static int rockchip_lvds_bind(struct device *dev, struct device *master,
return -EINVAL;
}
for_each_child_of_node(port, endpoint) {
+ child_count++;
of_property_read_u32(endpoint, "reg", &endpoint_id);
ret = drm_of_find_panel_or_bridge(dev->of_node, 1, endpoint_id,
&lvds->panel, &lvds->bridge);
if (!ret)
break;
}
- if (ret) {
+ if (!child_count) {
+ DRM_DEV_ERROR(dev, "lvds port does not have any children\n");
+ ret = -EINVAL;
+ goto err_put_port;
+ } else if (ret) {
DRM_DEV_ERROR(dev, "failed to find panel and bridge node\n");
ret = -EPROBE_DEFER;
goto err_put_port;
--
2.14.1.821.g8fa685d3b7-goog
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH] drm/rockchip: Fix uninitialized use of ret
@ 2017-09-21 0:13 ` Sean Paul
0 siblings, 0 replies; 5+ messages in thread
From: Sean Paul @ 2017-09-21 0:13 UTC (permalink / raw)
To: linux-arm-kernel
If there are no children for lvds, ret is used uninitialized. This patch
initializes ret and returns an error if the port has no children.
Fixes: 34cc0aa25456 ("drm/rockchip: Add support for Rockchip Soc LVDS")
Cc: Mark Yao <mark.yao@rock-chips.com>
Cc: Heiko Stuebner <heiko@sntech.de>
Cc: Sandy Huang <hjc@rock-chips.com>
Cc: dri-devel at lists.freedesktop.org
Cc: linux-arm-kernel at lists.infradead.org
Cc: linux-rockchip at lists.infradead.org
Signed-off-by: Sean Paul <seanpaul@chromium.org>
---
drivers/gpu/drm/rockchip/rockchip_lvds.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/rockchip/rockchip_lvds.c b/drivers/gpu/drm/rockchip/rockchip_lvds.c
index c5fbe533796c..0ce6205d8d80 100644
--- a/drivers/gpu/drm/rockchip/rockchip_lvds.c
+++ b/drivers/gpu/drm/rockchip/rockchip_lvds.c
@@ -346,7 +346,7 @@ static int rockchip_lvds_bind(struct device *dev, struct device *master,
struct drm_connector *connector;
struct device_node *remote = NULL;
struct device_node *port, *endpoint;
- int ret;
+ int ret = 0, child_count = 0;
const char *name;
u32 endpoint_id;
@@ -358,13 +358,18 @@ static int rockchip_lvds_bind(struct device *dev, struct device *master,
return -EINVAL;
}
for_each_child_of_node(port, endpoint) {
+ child_count++;
of_property_read_u32(endpoint, "reg", &endpoint_id);
ret = drm_of_find_panel_or_bridge(dev->of_node, 1, endpoint_id,
&lvds->panel, &lvds->bridge);
if (!ret)
break;
}
- if (ret) {
+ if (!child_count) {
+ DRM_DEV_ERROR(dev, "lvds port does not have any children\n");
+ ret = -EINVAL;
+ goto err_put_port;
+ } else if (ret) {
DRM_DEV_ERROR(dev, "failed to find panel and bridge node\n");
ret = -EPROBE_DEFER;
goto err_put_port;
--
2.14.1.821.g8fa685d3b7-goog
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] drm/rockchip: Fix uninitialized use of ret
2017-09-21 0:13 ` Sean Paul
(?)
@ 2017-09-21 1:03 ` Mark yao
2017-09-21 20:13 ` Sean Paul
-1 siblings, 1 reply; 5+ messages in thread
From: Mark yao @ 2017-09-21 1:03 UTC (permalink / raw)
To: Sean Paul, dri-devel; +Cc: linux-rockchip, linux-arm-kernel
[-- Attachment #1.1: Type: text/plain, Size: 2047 bytes --]
On 2017年09月21日 08:13, Sean Paul wrote:
> If there are no children for lvds, ret is used uninitialized. This patch
> initializes ret and returns an error if the port has no children.
>
> Fixes: 34cc0aa25456 ("drm/rockchip: Add support for Rockchip Soc LVDS")
> Cc: Mark Yao <mark.yao@rock-chips.com>
> Cc: Heiko Stuebner <heiko@sntech.de>
> Cc: Sandy Huang <hjc@rock-chips.com>
> Cc: dri-devel@lists.freedesktop.org
> Cc: linux-arm-kernel@lists.infradead.org
> Cc: linux-rockchip@lists.infradead.org
> Signed-off-by: Sean Paul <seanpaul@chromium.org>
> ---
> drivers/gpu/drm/rockchip/rockchip_lvds.c | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/rockchip/rockchip_lvds.c b/drivers/gpu/drm/rockchip/rockchip_lvds.c
> index c5fbe533796c..0ce6205d8d80 100644
> --- a/drivers/gpu/drm/rockchip/rockchip_lvds.c
> +++ b/drivers/gpu/drm/rockchip/rockchip_lvds.c
> @@ -346,7 +346,7 @@ static int rockchip_lvds_bind(struct device *dev, struct device *master,
> struct drm_connector *connector;
> struct device_node *remote = NULL;
> struct device_node *port, *endpoint;
> - int ret;
> + int ret = 0, child_count = 0;
> const char *name;
> u32 endpoint_id;
>
> @@ -358,13 +358,18 @@ static int rockchip_lvds_bind(struct device *dev, struct device *master,
> return -EINVAL;
> }
> for_each_child_of_node(port, endpoint) {
> + child_count++;
> of_property_read_u32(endpoint, "reg", &endpoint_id);
> ret = drm_of_find_panel_or_bridge(dev->of_node, 1, endpoint_id,
> &lvds->panel, &lvds->bridge);
> if (!ret)
> break;
> }
> - if (ret) {
> + if (!child_count) {
> + DRM_DEV_ERROR(dev, "lvds port does not have any children\n");
> + ret = -EINVAL;
Double space on "ret =", except this, looks good for me.
Reviewed-by: Mark Yao <mark.yao@rock-chips.com>
> + goto err_put_port;
> + } else if (ret) {
> DRM_DEV_ERROR(dev, "failed to find panel and bridge node\n");
> ret = -EPROBE_DEFER;
> goto err_put_port;
--
Mark Yao
[-- Attachment #1.2: Type: text/html, Size: 3747 bytes --]
[-- Attachment #2: Type: text/plain, Size: 160 bytes --]
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] drm/rockchip: Fix uninitialized use of ret
2017-09-21 1:03 ` Mark yao
@ 2017-09-21 20:13 ` Sean Paul
0 siblings, 0 replies; 5+ messages in thread
From: Sean Paul @ 2017-09-21 20:13 UTC (permalink / raw)
To: Mark yao; +Cc: dri-devel, open list:ARM/Rockchip SoC..., Linux ARM Kernel
On Wed, Sep 20, 2017 at 6:03 PM, Mark yao <mark.yao@rock-chips.com> wrote:
> On 2017年09月21日 08:13, Sean Paul wrote:
>
> If there are no children for lvds, ret is used uninitialized. This patch
> initializes ret and returns an error if the port has no children.
>
> Fixes: 34cc0aa25456 ("drm/rockchip: Add support for Rockchip Soc LVDS")
> Cc: Mark Yao <mark.yao@rock-chips.com>
> Cc: Heiko Stuebner <heiko@sntech.de>
> Cc: Sandy Huang <hjc@rock-chips.com>
> Cc: dri-devel@lists.freedesktop.org
> Cc: linux-arm-kernel@lists.infradead.org
> Cc: linux-rockchip@lists.infradead.org
> Signed-off-by: Sean Paul <seanpaul@chromium.org>
> ---
> drivers/gpu/drm/rockchip/rockchip_lvds.c | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/rockchip/rockchip_lvds.c
> b/drivers/gpu/drm/rockchip/rockchip_lvds.c
> index c5fbe533796c..0ce6205d8d80 100644
> --- a/drivers/gpu/drm/rockchip/rockchip_lvds.c
> +++ b/drivers/gpu/drm/rockchip/rockchip_lvds.c
> @@ -346,7 +346,7 @@ static int rockchip_lvds_bind(struct device *dev, struct
> device *master,
> struct drm_connector *connector;
> struct device_node *remote = NULL;
> struct device_node *port, *endpoint;
> - int ret;
> + int ret = 0, child_count = 0;
> const char *name;
> u32 endpoint_id;
>
> @@ -358,13 +358,18 @@ static int rockchip_lvds_bind(struct device *dev,
> struct device *master,
> return -EINVAL;
> }
> for_each_child_of_node(port, endpoint) {
> + child_count++;
> of_property_read_u32(endpoint, "reg", &endpoint_id);
> ret = drm_of_find_panel_or_bridge(dev->of_node, 1, endpoint_id,
> &lvds->panel, &lvds->bridge);
> if (!ret)
> break;
> }
> - if (ret) {
> + if (!child_count) {
> + DRM_DEV_ERROR(dev, "lvds port does not have any children\n");
> + ret = -EINVAL;
>
>
> Double space on "ret =", except this, looks good for me.
> Reviewed-by: Mark Yao <mark.yao@rock-chips.com>
>
Thanks for your review, Mark!
I've pushed the patch with whitespace fixes to -misc-next.
Sean
> + goto err_put_port;
> + } else if (ret) {
> DRM_DEV_ERROR(dev, "failed to find panel and bridge node\n");
> ret = -EPROBE_DEFER;
> goto err_put_port;
>
>
> --
> Mark Yao
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] drm/rockchip: Fix uninitialized use of ret
@ 2017-09-21 20:13 ` Sean Paul
0 siblings, 0 replies; 5+ messages in thread
From: Sean Paul @ 2017-09-21 20:13 UTC (permalink / raw)
To: linux-arm-kernel
On Wed, Sep 20, 2017 at 6:03 PM, Mark yao <mark.yao@rock-chips.com> wrote:
> On 2017?09?21? 08:13, Sean Paul wrote:
>
> If there are no children for lvds, ret is used uninitialized. This patch
> initializes ret and returns an error if the port has no children.
>
> Fixes: 34cc0aa25456 ("drm/rockchip: Add support for Rockchip Soc LVDS")
> Cc: Mark Yao <mark.yao@rock-chips.com>
> Cc: Heiko Stuebner <heiko@sntech.de>
> Cc: Sandy Huang <hjc@rock-chips.com>
> Cc: dri-devel at lists.freedesktop.org
> Cc: linux-arm-kernel at lists.infradead.org
> Cc: linux-rockchip at lists.infradead.org
> Signed-off-by: Sean Paul <seanpaul@chromium.org>
> ---
> drivers/gpu/drm/rockchip/rockchip_lvds.c | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/rockchip/rockchip_lvds.c
> b/drivers/gpu/drm/rockchip/rockchip_lvds.c
> index c5fbe533796c..0ce6205d8d80 100644
> --- a/drivers/gpu/drm/rockchip/rockchip_lvds.c
> +++ b/drivers/gpu/drm/rockchip/rockchip_lvds.c
> @@ -346,7 +346,7 @@ static int rockchip_lvds_bind(struct device *dev, struct
> device *master,
> struct drm_connector *connector;
> struct device_node *remote = NULL;
> struct device_node *port, *endpoint;
> - int ret;
> + int ret = 0, child_count = 0;
> const char *name;
> u32 endpoint_id;
>
> @@ -358,13 +358,18 @@ static int rockchip_lvds_bind(struct device *dev,
> struct device *master,
> return -EINVAL;
> }
> for_each_child_of_node(port, endpoint) {
> + child_count++;
> of_property_read_u32(endpoint, "reg", &endpoint_id);
> ret = drm_of_find_panel_or_bridge(dev->of_node, 1, endpoint_id,
> &lvds->panel, &lvds->bridge);
> if (!ret)
> break;
> }
> - if (ret) {
> + if (!child_count) {
> + DRM_DEV_ERROR(dev, "lvds port does not have any children\n");
> + ret = -EINVAL;
>
>
> Double space on "ret =", except this, looks good for me.
> Reviewed-by: Mark Yao <mark.yao@rock-chips.com>
>
Thanks for your review, Mark!
I've pushed the patch with whitespace fixes to -misc-next.
Sean
> + goto err_put_port;
> + } else if (ret) {
> DRM_DEV_ERROR(dev, "failed to find panel and bridge node\n");
> ret = -EPROBE_DEFER;
> goto err_put_port;
>
>
> --
> ?ark Yao
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2017-09-21 20:13 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-21 0:13 [PATCH] drm/rockchip: Fix uninitialized use of ret Sean Paul
2017-09-21 0:13 ` Sean Paul
2017-09-21 1:03 ` Mark yao
2017-09-21 20:13 ` Sean Paul
2017-09-21 20:13 ` Sean Paul
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.