Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

video: fbdev: amba-clcd: Fix refcount leak bugs

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.

Fixes: d10715be03bd ("video: ARM CLCD: Add DT support")
Signed-off-by: Liang He <windhl@126.com>
Signed-off-by: Helge Deller <deller@gmx.de>

authored by

Liang He and committed by
Helge Deller
26c2b7d9 075fbf0a

+18 -6
+18 -6
drivers/video/fbdev/amba-clcd.c
··· 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); ··· 738 736 739 737 if (of_property_read_u32_array(endpoint, 740 738 "arm,pl11x,tft-r0g0b0-pads", 741 - tft_r0b0g0, ARRAY_SIZE(tft_r0b0g0)) != 0) 742 - return -ENOENT; 739 + tft_r0b0g0, ARRAY_SIZE(tft_r0b0g0)) != 0) { 740 + err = -ENOENT; 741 + goto out_panel_put; 742 + } 743 + 744 + of_node_put(panel); 745 + of_node_put(endpoint); 743 746 744 747 return clcdfb_of_init_tft_panel(fb, tft_r0b0g0[0], 745 748 tft_r0b0g0[1], tft_r0b0g0[2]); 749 + out_panel_put: 750 + of_node_put(panel); 751 + out_endpoint_put: 752 + of_node_put(endpoint); 753 + return err; 746 754 } 747 755 748 756 static int clcdfb_of_vram_setup(struct clcd_fb *fb)