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 | 698 | return -ENODEV; |
| 699 | 699 | |
| 700 | 700 | panel = of_graph_get_remote_port_parent(endpoint); |
| 701 | − if (!panel) | |
| 702 | − return -ENODEV; | |
| 701 | + if (!panel) { | |
| 702 | + err = -ENODEV; | |
| 703 | + goto out_endpoint_put; | |
| 704 | + } | |
| 703 | 705 | |
| 704 | 706 | err = clcdfb_of_get_backlight(&fb->dev->dev, fb->panel); |
| 705 | 707 | if (err) |
| 706 | − return err; | |
| 708 | + goto out_panel_put; | |
| 707 | 709 | |
| 708 | 710 | err = clcdfb_of_get_mode(&fb->dev->dev, panel, fb->panel); |
| 709 | 711 | if (err) |
| 710 | − return err; | |
| 712 | + goto out_panel_put; | |
| 711 | 713 | |
| 712 | 714 | err = of_property_read_u32(fb->dev->dev.of_node, "max-memory-bandwidth", |
| 713 | 715 | &max_bandwidth); |
| @@ -736,11 +738,21 @@ static int clcdfb_of_init_display(struct clcd_fb *fb) · 22 unmodified lines | ||
| 736 | 738 | |
| 737 | 739 | if (of_property_read_u32_array(endpoint, |
| 738 | 740 | "arm,pl11x,tft-r0g0b0-pads", |
| 739 | − tft_r0b0g0, ARRAY_SIZE(tft_r0b0g0)) != 0) | |
| 740 | − return -ENOENT; | |
| 741 | + tft_r0b0g0, ARRAY_SIZE(tft_r0b0g0)) != 0) { | |
| 742 | + err = -ENOENT; | |
| 743 | + goto out_panel_put; | |
| 744 | + } | |
| 745 | + | |
| 746 | + of_node_put(panel); | |
| 747 | + of_node_put(endpoint); | |
| 741 | 748 | |
| 742 | 749 | return clcdfb_of_init_tft_panel(fb, tft_r0b0g0[0], |
| 743 | 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 | 758 | static int clcdfb_of_vram_setup(struct clcd_fb *fb) |