Skip to content

Commit d65bfb9

Browse files
shivanigupta-devdaeinki
authored andcommitted
gpu: drm: exynos: hdmi: eliminate uses of of_node_put()
Utilize the __free() cleanup handler within the hdmi_get_phy_io function to automatically release the device node when it is out of scope. This eliminates the manual invocation of of_node_put(), reducing the potential for memory leaks. The modification requires initializing the device node at the beginning of the function, ensuring that the automatic cleanup is safely executed. Consequently, this removes the need for error cleanup paths that utilize goto statements and the jump to out is no longer necessary. Suggested-by: Julia Lawall <[email protected]> Signed-off-by: Shivani Gupta <[email protected]> Signed-off-by: Inki Dae <[email protected]>
1 parent edb8e86 commit d65bfb9

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

drivers/gpu/drm/exynos/exynos_hdmi.c

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1919,10 +1919,9 @@ static int hdmi_get_ddc_adapter(struct hdmi_context *hdata)
19191919
static int hdmi_get_phy_io(struct hdmi_context *hdata)
19201920
{
19211921
const char *compatible_str = "samsung,exynos4212-hdmiphy";
1922-
struct device_node *np;
1923-
int ret = 0;
1922+
struct device_node *np __free(device_node) =
1923+
of_find_compatible_node(NULL, NULL, compatible_str);
19241924

1925-
np = of_find_compatible_node(NULL, NULL, compatible_str);
19261925
if (!np) {
19271926
np = of_parse_phandle(hdata->dev->of_node, "phy", 0);
19281927
if (!np) {
@@ -1937,21 +1936,17 @@ static int hdmi_get_phy_io(struct hdmi_context *hdata)
19371936
if (!hdata->regs_hdmiphy) {
19381937
DRM_DEV_ERROR(hdata->dev,
19391938
"failed to ioremap hdmi phy\n");
1940-
ret = -ENOMEM;
1941-
goto out;
1939+
return -ENOMEM;
19421940
}
19431941
} else {
19441942
hdata->hdmiphy_port = of_find_i2c_device_by_node(np);
19451943
if (!hdata->hdmiphy_port) {
19461944
DRM_INFO("Failed to get hdmi phy i2c client\n");
1947-
ret = -EPROBE_DEFER;
1948-
goto out;
1945+
return -EPROBE_DEFER;
19491946
}
19501947
}
19511948

1952-
out:
1953-
of_node_put(np);
1954-
return ret;
1949+
return 0;
19551950
}
19561951

19571952
static int hdmi_probe(struct platform_device *pdev)

0 commit comments

Comments
 (0)