History

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.

Liang He committed 4 years ago

Commit 26c2b7d1 parent 075fbf01 file · +18 −6Browse files

Unified · Split

drivers/video/fbdev/amba-clcd.c+18−6
@@ -698,16 +698,18 @@ static int clcdfb_of_init_display(struct clcd_fb *fb) · 697 unmodified lines
698698 return -ENODEV;
699699
700700 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+ }
703705
704706 err = clcdfb_of_get_backlight(&fb->dev->dev, fb->panel);
705707 if (err)
706− return err;
708+ goto out_panel_put;
707709
708710 err = clcdfb_of_get_mode(&fb->dev->dev, panel, fb->panel);
709711 if (err)
710− return err;
712+ goto out_panel_put;
711713
712714 err = of_property_read_u32(fb->dev->dev.of_node, "max-memory-bandwidth",
713715 &max_bandwidth);
@@ -736,11 +738,21 @@ static int clcdfb_of_init_display(struct clcd_fb *fb) · 22 unmodified lines
736738
737739 if (of_property_read_u32_array(endpoint,
738740 "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);
741748
742749 return clcdfb_of_init_tft_panel(fb, tft_r0b0g0[0],
743750 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;
744756 }
745757
746758 static int clcdfb_of_vram_setup(struct clcd_fb *fb)