Skip to content

Commit e8596ca

Browse files
yuwatakeszybz
authored andcommitted
backlight: do not unref parent device
Fixes double-free introduced by 9aadd28.
1 parent 3f9233e commit e8596ca

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/backlight/backlight.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,12 @@ static int find_pci_or_platform_parent(sd_device *device, sd_device **ret) {
6161

6262
/* Graphics card */
6363
if (class == 0x30000) {
64-
*ret = TAKE_PTR(parent);
64+
*ret = parent;
6565
return 0;
6666
}
6767

6868
} else if (streq(subsystem, "platform")) {
69-
*ret = TAKE_PTR(parent);
69+
*ret = parent;
7070
return 0;
7171
}
7272

@@ -104,9 +104,8 @@ static int same_device(sd_device *a, sd_device *b) {
104104

105105
static int validate_device(sd_device *device) {
106106
_cleanup_(sd_device_enumerator_unrefp) sd_device_enumerator *enumerate = NULL;
107-
_cleanup_(sd_device_unrefp) sd_device *parent = NULL;
108107
const char *v, *subsystem;
109-
sd_device *other;
108+
sd_device *parent, *other;
110109
int r;
111110

112111
assert(device);
@@ -162,8 +161,8 @@ static int validate_device(sd_device *device) {
162161
return r;
163162

164163
FOREACH_DEVICE_AND_SUBSYSTEM(enumerate, other) {
165-
_cleanup_(sd_device_unrefp) sd_device *other_parent = NULL;
166164
const char *other_subsystem;
165+
sd_device *other_parent;
167166

168167
if (same_device(device, other) > 0)
169168
continue;

0 commit comments

Comments
 (0)