]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: fix memleak
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 7 Jul 2020 03:17:46 +0000 (12:17 +0900)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 7 Jul 2020 06:23:17 +0000 (08:23 +0200)
If init() is failed, the allocated memory was leaked.

src/network/tc/qdisc.c
src/network/tc/tclass.c

index 91cdd8917f53798235f33e3c0c61db47abf2abbb..c2b6c1de2fb4860dc5681e63b6fef70c74212fe6 100644 (file)
@@ -39,7 +39,7 @@ const QDiscVTable * const qdisc_vtable[_QDISC_KIND_MAX] = {
 };
 
 static int qdisc_new(QDiscKind kind, QDisc **ret) {
-        QDisc *qdisc;
+        _cleanup_(qdisc_freep) QDisc *qdisc = NULL;
         int r;
 
         if (kind == _QDISC_KIND_INVALID) {
index 4f75e1b42dcdb740d15eaaf13f91934369a78b76..a89e7757ad08f414fdfdfa31dbb899e2ab3139fa 100644 (file)
@@ -22,7 +22,7 @@ const TClassVTable * const tclass_vtable[_TCLASS_KIND_MAX] = {
 };
 
 static int tclass_new(TClassKind kind, TClass **ret) {
-        TClass *tclass;
+        _cleanup_(tclass_freep) TClass *tclass = NULL;
         int r;
 
         tclass = malloc0(tclass_vtable[kind]->object_size);