Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-12-SP5:Update
ndctl
ndctl-dimm-fix-potential-fd-leakage-in-dimm_act...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File ndctl-dimm-fix-potential-fd-leakage-in-dimm_action.patch of Package ndctl
From ff434d87ccbd46c672f187e30d2727431e1599c3 Mon Sep 17 00:00:00 2001 From: Zhiqiang Liu <liuzhiqiang26@huawei.com> Date: Fri, 6 Nov 2020 17:26:12 +0800 Subject: [PATCH] dimm: fix potential fd leakage in dimm_action() References: bsc#1170384 Patch-mainline: v71 Git-commit: ff434d87ccbd46c672f187e30d2727431e1599c3 In dimm_action(), actx.f_out and actx.f_in may be set by calling fopen(). If exceptions occur, we will directly goto out tag. However, we did not close actx.f_out|actx.f_in in out tag, which will cause fd leakage. Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com> Signed-off-by: Vishal Verma <vishal.l.verma@intel.com> Acked-by: Jeff Moyer <jmoyer@redhat.com> Link: https://lore.kernel.org/r/1ca17cf4-a5fd-786d-fa50-8ed09ccd55e4@huawei.com --- ndctl/dimm.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff -ur ndctl-64.1.orig/ndctl/dimm.c ndctl-64.1/ndctl/dimm.c --- ndctl-64.1.orig/ndctl/dimm.c 2021-01-06 14:47:56.801746208 +0100 +++ ndctl-64.1/ndctl/dimm.c 2021-01-06 15:26:14.125088677 +0100 @@ -1162,7 +1162,8 @@ if (!param.infile) { if (action == action_update) { usage_with_options(u, options); - return -EINVAL; + rc = -EINVAL; + goto out_close_fout; } actx.f_in = stdin; } else { @@ -1171,7 +1172,7 @@ fprintf(stderr, "failed to open: %s: (%s)\n", param.infile, strerror(errno)); rc = -errno; - goto out; + goto out_close_fout; } } @@ -1190,7 +1191,7 @@ fprintf(stderr, "'%s' is not a valid label version\n", param.labelversion); rc = -EINVAL; - goto out; + goto out_close_fin_fout; } rc = 0; @@ -1229,7 +1230,8 @@ if (count > 1) { error("write-labels only supports writing a single dimm\n"); usage_with_options(u, options); - return -EINVAL; + rc = -EINVAL; + goto out_close_fin_fout; } else if (single) rc = action(single, &actx); } @@ -1237,12 +1239,14 @@ if (actx.jdimms) util_display_json_array(actx.f_out, actx.jdimms, 0); - if (actx.f_out != stdout) - fclose(actx.f_out); - + out_close_fin_fout: if (actx.f_in != stdin) fclose(actx.f_in); + out_close_fout: + if (actx.f_out != stdout) + fclose(actx.f_out); + out: /* * count if some actions succeeded, 0 if none were attempted,
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor