From: Christopher Michael Date: Thu, 25 Feb 2021 15:02:07 +0000 (-0500) Subject: eeze_disk: fix potential memory leak X-Git-Tag: accepted/tizen/unified/20210602.122542~13 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=321d46aae68b7d543e0acc9f779a063a7151bc41;p=platform%2Fupstream%2Fefl.git eeze_disk: fix potential memory leak If allocation for disk fails, then we leak memory from previously called _new_device function. This patch based on D12223 from akanad (Wonki Kim) ref D12223 Change-Id: If22a28d99a6b91eadc1b82103daabf92db515923 --- diff --git a/src/lib/eeze/eeze_disk.c b/src/lib/eeze/eeze_disk.c index 60c4fa7..9469f47 100644 --- a/src/lib/eeze/eeze_disk.c +++ b/src/lib/eeze/eeze_disk.c @@ -176,7 +176,11 @@ eeze_disk_new(const char *path) if (!(disk = calloc(1, sizeof(Eeze_Disk)))) - return NULL; + { + eina_stringshare_del(syspath); + udev_device_unref(dev); + return NULL; + } if (is_dev) @@ -187,7 +191,6 @@ eeze_disk_new(const char *path) else disk->syspath = eina_stringshare_add(udev_device_get_syspath(dev)); - disk->device = dev; disk->mount_opts = EEZE_DISK_MOUNTOPT_DEFAULTS; disk->mount_cmd_changed = EINA_TRUE;