summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMarcel Hollerbach <mail@marcel-hollerbach.de>2021-03-15 14:01:32 +0100
committerMarcel Hollerbach <mail@marcel-hollerbach.de>2021-03-15 14:16:34 +0100
commit046c5cd58e1feb8760a1fbf4a1bb4253ed40f947 (patch)
tree84943481030bd5b7e5d3b8a06ac9efcd10051db1 /src
parent3cd6191409207813a3801c584996fa1942e0f9d1 (diff)
eeze_scanner: do not crash
the free logic here was wrong. The udev_device_get_parent results get automatically unrefed when the original device is deleted. This caused random segfaults when starting e.
Diffstat (limited to 'src')
-rw-r--r--src/lib/eeze/eeze_udev_walk.c18
1 files changed, 6 insertions, 12 deletions
diff --git a/src/lib/eeze/eeze_udev_walk.c b/src/lib/eeze/eeze_udev_walk.c
index 4cd661b184..5df34178a8 100644
--- a/src/lib/eeze/eeze_udev_walk.c
+++ b/src/lib/eeze/eeze_udev_walk.c
@@ -40,7 +40,7 @@ EAPI const char *
40eeze_udev_walk_get_sysattr(const char *syspath, 40eeze_udev_walk_get_sysattr(const char *syspath,
41 const char *sysattr) 41 const char *sysattr)
42{ 42{
43 _udev_device *device, *child, *parent; 43 _udev_device *device, *parent;
44 const char *test = NULL; 44 const char *test = NULL;
45 45
46 if (!syspath) 46 if (!syspath)
@@ -49,18 +49,12 @@ eeze_udev_walk_get_sysattr(const char *syspath,
49 if (!(device = _new_device(syspath))) 49 if (!(device = _new_device(syspath)))
50 return NULL; 50 return NULL;
51 51
52 for (parent = device; parent;) 52 for (parent = device; parent && !test;)
53 { 53 {
54 if ((test = udev_device_get_sysattr_value(parent, sysattr))) 54 test = udev_device_get_sysattr_value(parent, sysattr);
55 { 55 parent = udev_device_get_parent(parent);
56 test = eina_stringshare_add(test);
57 udev_device_unref(parent);
58 return test;
59 }
60 child = parent;
61 parent = udev_device_get_parent(child);
62 udev_device_unref(child);
63 } 56 }
64 57
65 return NULL; 58 udev_device_unref(device);
59 return eina_stringshare_add(test);
66} 60}