open-iscsi/0006-Resource-leak-Variable-rec-going-out-of-scope-leaks.patch

35 lines
940 B
Diff
Raw Normal View History

2020-01-09 16:12:53 +08:00
From 0db12353efea69309a6a92f30f4e063b142359c4 Mon Sep 17 00:00:00 2001
From: Chris Leech <cleech@redhat.com>
Date: Wed, 30 Oct 2019 11:27:07 -0700
Subject: [PATCH 20/43] Resource leak: Variable rec going out of scope leaks
the storage it points to
---
usr/iscsiadm.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/usr/iscsiadm.c b/usr/iscsiadm.c
index 8de7a41..2ce6ae7 100644
--- a/usr/iscsiadm.c
+++ b/usr/iscsiadm.c
@@ -1044,7 +1044,7 @@ static int add_static_rec(int *found, char *targetname, int tpgt,
if (rc) {
log_error("Could not read iface %s. Error %d",
iface->name, rc);
- return rc;
+ goto free_drec;
}
iface_copy(&rec->iface, iface);
@@ -1057,6 +1057,7 @@ static int add_static_rec(int *found, char *targetname, int tpgt,
rec->iface.transport_name, iface_str(&rec->iface),
ip, port, tpgt, targetname);
}
+free_drec:
free(drec);
free_rec:
free(rec);
--
2.19.1