]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
udev: fix memleak
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 21 Dec 2020 06:28:19 +0000 (15:28 +0900)
committerFrantisek Sumsal <frantisek@sumsal.cz>
Mon, 21 Dec 2020 15:55:56 +0000 (16:55 +0100)
Fixes #18039.

src/udev/udev-node.c

index d21be61ae59162a2d1fdc95c60bf76ec576a2f12..96963a4343ef5cc2a9cd424eaeb94803242d507e 100644 (file)
@@ -227,7 +227,7 @@ static size_t escape_path(const char *src, char *dest, size_t size) {
 
 /* manage "stack of names" with possibly specified device priorities */
 static int link_update(sd_device *dev, const char *slink, bool add) {
-        _cleanup_free_ char *target = NULL, *filename = NULL, *dirname = NULL;
+        _cleanup_free_ char *filename = NULL, *dirname = NULL;
         char name_enc[PATH_MAX];
         const char *id_filename;
         int i, r, retries;
@@ -270,6 +270,7 @@ static int link_update(sd_device *dev, const char *slink, bool add) {
         retries = sd_device_get_is_initialized(dev) > 0 ? LINK_UPDATE_MAX_RETRIES : 1;
 
         for (i = 0; i < retries; i++) {
+                _cleanup_free_ char *target = NULL;
                 struct stat st1 = {}, st2 = {};
 
                 r = stat(dirname, &st1);