Re: [PATCH] drm/rockchip: Fix uninitialized use of ret

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxx>
Cc: Heiko Stuebner <heiko@xxxxxxxxx>
Cc: Sandy Huang <hjc@xxxxxxxxxxxxxx>
Cc: dri-devel@xxxxxxxxxxxxxxxxxxxxx
Cc: linux-arm-kernel@xxxxxxxxxxxxxxxxxxx
Cc: linux-rockchip@xxxxxxxxxxxxxxxxxxx
Signed-off-by: Sean Paul <seanpaul@xxxxxxxxxxxx>
---
 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@xxxxxxxxxxxxxx>

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

[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux