diff --git a/u-boot/drivers/video/drm/dw_mipi_dsi.c b/u-boot/drivers/video/drm/dw_mipi_dsi.c
index 52fb4ffee..230b2d9c0 100755
--- a/u-boot/drivers/video/drm/dw_mipi_dsi.c
+++ b/u-boot/drivers/video/drm/dw_mipi_dsi.c
@@ -1325,33 +1325,58 @@ static int dw_mipi_dsi_connector_disable(struct rockchip_connector *conn,
 
 static int dw_mipi_dsi_connector_fixup_dts(struct display_state *state, void *blob)
 {
-	//struct connector_state *conn_state = &state->conn_state; 
 	struct panel_state *panel_state = &state->panel_state;
-    int num = panel_state->panel->num;	
+	struct connector_state *conn_state = &state->conn_state;
 	const struct device_node *np;
 	const char *path;
-	int panel_node,connector;
-	struct connector_state * conn_state = &state->conn_state;
+	int panel_node, connector;
+	int num = -1;
+	int first_panel_num = -1;
+
+	if (panel_state->panel)
+		num = panel_state->panel->num;
 
-	
 	np = ofnode_to_np(conn_state->node);
+	if (!np)
+		return 0;
+
 	path = np->full_name;
+	if (!path)
+		return 0;
+
 	connector = fdt_path_offset(blob, path);
+	if (connector < 0)
+		return 0;
 
 	for (panel_node = fdt_subnode_offset(blob, connector, "panel");
 	     panel_node >= 0;
-	     panel_node = fdt_next_subnode(blob, panel_node)){
- 
-		 dbg("fixup panel(num=%d) target =%d\n",fdtdec_get_int(blob, panel_node, "num", 0),num);
+	     panel_node = fdt_next_subnode(blob, panel_node)) {
+		int panel_num = fdtdec_get_int(blob, panel_node, "num", -1);
+
+		if (first_panel_num < 0)
+			first_panel_num = panel_num;
+	}
 
-	    if(fdtdec_get_int(blob, panel_node, "num", 0) != num){
-			dbg("disable num :%d",fdtdec_get_int(blob, panel_node, "num", 0));
+	if (num < 0) {
+		num = first_panel_num;
+		printf("DSI-READ: invalid target panel, fallback to num=%d\n", num);
+	}
+
+	for (panel_node = fdt_subnode_offset(blob, connector, "panel");
+	     panel_node >= 0;
+	     panel_node = fdt_next_subnode(blob, panel_node)) {
+		int panel_num = fdtdec_get_int(blob, panel_node, "num", -1);
+
+		debug("fixup panel(num=%d) target =%d\n", panel_num, num);
+
+		if (panel_num != num) {
+			debug("disable num :%d\n", panel_num);
 			fdt_status_disabled(blob, panel_node);
-	    }else{
-			dbg("ok num :%d",fdtdec_get_int(blob, panel_node, "num", 0));
+		} else {
+			debug("ok num :%d\n", panel_num);
 			fdt_status_okay(blob, panel_node);
 		}
-	 }
+	}
 
 	return 0;
 }
diff --git a/u-boot/drivers/video/drm/rockchip_panel.c b/u-boot/drivers/video/drm/rockchip_panel.c
index c1b2c0730..baf0ed821 100755
--- a/u-boot/drivers/video/drm/rockchip_panel.c
+++ b/u-boot/drivers/video/drm/rockchip_panel.c
@@ -408,16 +408,36 @@ static void panel_simple_init(struct rockchip_panel *panel)
 
 static int rockchip_dsi_panel_getId(struct rockchip_panel *panel)
 {
-	u8 *buf;
-	int i,len,ret = -1;
+	u8 *buf = NULL;
+	int i;
+	int len;
+	int ret = -1;
 	int count = 3;
-
 	struct rockchip_panel_plat *plat = dev_get_platdata(panel->dev);
 	struct rockchip_panel_priv *priv = dev_get_priv(panel->dev);
 	struct mipi_dsi_device *dsi = dev_get_parent_platdata(panel->dev);
 
+	if (!plat || !priv || !dsi) {
+		if (plat)
+			plat->num = -1;
+		panel->num = -1;
+		return -ENODEV;
+	}
+
+	if (!plat->id || !plat->id->buf || plat->id->len <= 0) {
+		printf("DSI-READ: invalid panel id config\n");
+		plat->num = -1;
+		panel->num = -1;
+		return -ENODEV;
+	}
+
 	len = plat->id->len;
-	buf = malloc(sizeof(char) * len);
+	buf = calloc(len, sizeof(u8));
+	if (!buf) {
+		plat->num = -1;
+		panel->num = -1;
+		return -ENOMEM;
+	}
 
 	if (priv->power_supply)
 		regulator_set_enable(priv->power_supply, !plat->power_invert);
@@ -441,46 +461,70 @@ static int rockchip_dsi_panel_getId(struct rockchip_panel *panel)
 		mdelay(plat->delay.init);
 	priv->prepared = true;
 
-	
 	if (plat->read_id_cmds) {
-		rockchip_panel_send_dsi_cmds(dsi, plat->read_id_cmds);
-	    free(plat->read_id_cmds);
-		plat->read_id_cmds = NULL;
-	}else{
-		if (plat->on_cmds) {
+		ret = rockchip_panel_send_dsi_cmds(dsi, plat->read_id_cmds);
+		if (ret) {
+			printf("failed to send read id cmds: %d\n", ret);
+			plat->num = -1;
+			panel->num = -1;
+			free(buf);
+			return ret;
+		}
+	} else if (plat->on_cmds) {
 		ret = rockchip_panel_send_dsi_cmds(dsi, plat->on_cmds);
-		if (ret)
+		if (ret) {
 			printf("failed to send on cmds: %d\n", ret);
-	   }
-
+			plat->num = -1;
+			panel->num = -1;
+			free(buf);
+			return ret;
+		}
 	}
 
-  ret = -1;
-	while((ret < 0) && count > 0){
-		if(len > 1){
+	ret = -1;
+	while ((ret < 0) && count > 0) {
+		if (len > 1) {
 			ret = mipi_dsi_set_maximum_return_packet_size(dsi, len);
+			if (ret < 0) {
+				count--;
+				continue;
+			}
 		}
-		ret = mipi_dsi_dcs_read(dsi, plat->id_reg, buf,len);
-		count --;
+		ret = mipi_dsi_dcs_read(dsi, plat->id_reg, buf, len);
+		count--;
 	}
-	  printf("Read ID: ID1= 0x%02x , ID2 = 0x%02x , ID3 = 0x%02x \n",buf[0],buf[1],buf[2]);
- 	  printf("len=%d，ret=%d \n",len,ret);
-	  printf("panel ID: ID1= 0x%02x , ID2 = 0x%02x , ID3 = 0x%02x \n",plat->id->buf[0],plat->id->buf[1],plat->id->buf[2]);
-	//  printf("panel_simple_prepare buf = %d \n",buf[0]);
-	if(ret == len)
-		for(i = 0; i < len; i++){
-			printf("read buf id[%d] = %x,panel target id[%d] = %x\n", i, *(buf + i), i, *(plat->id->buf + i));
-			if(*(buf + i) != *(plat->id->buf + i)){
+
+	printf("Read ID: ID1= 0x%02x , ID2 = 0x%02x , ID3 = 0x%02x \n",
+	       len > 0 ? buf[0] : 0,
+	       len > 1 ? buf[1] : 0,
+	       len > 2 ? buf[2] : 0);
+	printf("len=%d，ret=%d \n", len, ret);
+	printf("panel ID: ID1= 0x%02x , ID2 = 0x%02x , ID3 = 0x%02x \n",
+	       len > 0 ? plat->id->buf[0] : 0,
+	       len > 1 ? plat->id->buf[1] : 0,
+	       len > 2 ? plat->id->buf[2] : 0);
+
+	if (ret == len) {
+		for (i = 0; i < len; i++) {
+			printf("read buf id[%d] = %x,panel target id[%d] = %x\n",
+			       i, *(buf + i), i, *(plat->id->buf + i));
+			if (*(buf + i) != *(plat->id->buf + i)) {
 				plat->num = -1;
+				panel->num = -1;
+				free(buf);
 				return -1;
 			}
 		}
-	else{
-		    dbg("read panel(num = %d) timeout or no response\n",plat->num);
-			plat->num = -1;
-			return -1;
+	} else {
+		dbg("read panel(num = %d) timeout or no response\n", plat->num);
+		plat->num = -1;
+		panel->num = -1;
+		free(buf);
+		return -1;
 	}
+
 	panel->num = plat->num;
+	free(buf);
 	return 0;
 }
 
