In clcdfb_of_init_display(), we should call of_node_put() for the references returned by of_graph_get_next_endpoint() and of_graph_get_remote_port_parent() which have increased the refcount. Besides, we should call of_node_put() both in fail path or when the references are not used anymore.
Unified · Split
| @@ -698,16 +698,18 @@ static int clcdfb_of_init_display(struct clcd_fb *fb) · 697 unmodified lines | |||
| 698 | return -ENODEV; | 698 | return -ENODEV; |
| 699 | 699 | ||
| 700 | panel = of_graph_get_remote_port_parent(endpoint); | 700 | panel = of_graph_get_remote_port_parent(endpoint); |
| 701 | if (!panel) | 701 | if (!panel) { |
| 702 | return -ENODEV; | 702 | err = -ENODEV; |
| 703 | goto out_endpoint_put; | ||
| 704 | } | ||
| 703 | 705 | ||
| 704 | err = clcdfb_of_get_backlight(&fb->dev->dev, fb->panel); | 706 | err = clcdfb_of_get_backlight(&fb->dev->dev, fb->panel); |
| 705 | if (err) | 707 | if (err) |
| 706 | return err; | 708 | goto out_panel_put; |
| 707 | 709 | ||
| 708 | err = clcdfb_of_get_mode(&fb->dev->dev, panel, fb->panel); | 710 | err = clcdfb_of_get_mode(&fb->dev->dev, panel, fb->panel); |
| 709 | if (err) | 711 | if (err) |
| 710 | return err; | 712 | goto out_panel_put; |
| 711 | 713 | ||
| 712 | err = of_property_read_u32(fb->dev->dev.of_node, "max-memory-bandwidth", | 714 | err = of_property_read_u32(fb->dev->dev.of_node, "max-memory-bandwidth", |
| 713 | &max_bandwidth); | 715 | &max_bandwidth); |
| @@ -736,11 +738,21 @@ static int clcdfb_of_init_display(struct clcd_fb *fb) · 22 unmodified lines | |||
| 736 | 738 | ||
| 737 | if (of_property_read_u32_array(endpoint, | 739 | if (of_property_read_u32_array(endpoint, |
| 738 | "arm,pl11x,tft-r0g0b0-pads", | 740 | "arm,pl11x,tft-r0g0b0-pads", |
| 739 | tft_r0b0g0, ARRAY_SIZE(tft_r0b0g0)) != 0) | 741 | tft_r0b0g0, ARRAY_SIZE(tft_r0b0g0)) != 0) { |
| 740 | return -ENOENT; | 742 | err = -ENOENT; |
| 743 | goto out_panel_put; | ||
| 744 | } | ||
| 745 | |||
| 746 | of_node_put(panel); | ||
| 747 | of_node_put(endpoint); | ||
| 741 | 748 | ||
| 742 | return clcdfb_of_init_tft_panel(fb, tft_r0b0g0[0], | 749 | return clcdfb_of_init_tft_panel(fb, tft_r0b0g0[0], |
| 743 | tft_r0b0g0[1], tft_r0b0g0[2]); | 750 | tft_r0b0g0[1], tft_r0b0g0[2]); |
| 751 | out_panel_put: | ||
| 752 | of_node_put(panel); | ||
| 753 | out_endpoint_put: | ||
| 754 | of_node_put(endpoint); | ||
| 755 | return err; | ||
| 744 | } | 756 | } |
| 745 | 757 | ||
| 746 | static int clcdfb_of_vram_setup(struct clcd_fb *fb) | 758 | static int clcdfb_of_vram_setup(struct clcd_fb *fb) |