summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmit Shah <amit.shah@redhat.com>2010-08-25 13:42:03 +0530
committerAmit Shah <amit.shah@redhat.com>2010-08-25 13:42:03 +0530
commiteb36ec2bfcdbb2d469873c4acc94aa7c3144c546 (patch)
treece430a3344e92be6a7da7257c821bdf9798ab4e9
parentf46c29597cd8960e5b5f5b23331b1c0164dd2c57 (diff)
downloadtest-virtserial-eb36ec2bfcdbb2d469873c4acc94aa7c3144c546.tar.gz
test-virtserial-eb36ec2bfcdbb2d469873c4acc94aa7c3144c546.tar.xz
test-virtserial-eb36ec2bfcdbb2d469873c4acc94aa7c3144c546.zip
auto-virtserial-guest: Fix a memleak in port open function
We leaked 30 bytes of memory for each open() call for a guest port. Signed-off-by: Amit Shah <amit.shah@redhat.com>
-rw-r--r--auto-virtserial-guest.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/auto-virtserial-guest.c b/auto-virtserial-guest.c
index b0faa10..cef1d26 100644
--- a/auto-virtserial-guest.c
+++ b/auto-virtserial-guest.c
@@ -153,7 +153,9 @@ static int open_port(int nr)
buf = get_port_dev(nr);
if (!buf)
return -ENOMEM;
- fd = open(get_port_dev(nr), O_RDWR);
+ fd = open(buf, O_RDWR);
+ free(buf);
+
if (fd == -1)
return -errno;
g_fd = fd;