aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Mykyta Holubakha <hilobakho@gmail.com>2017-01-15 14:25:29 +0200
committerGravatar Mykyta Holubakha <hilobakho@gmail.com>2017-01-15 14:25:29 +0200
commit760329d91f844b9f0ad63e866d8b9a4395fe52c1 (patch)
tree4b3577e1b0299befc153e3fb27e67777c5358e7f
parent3554aca4181ede432725fef82c171f584b284e67 (diff)
Fix a null-pointer dereference in read_device
-rw-r--r--brightnessctl.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/brightnessctl.c b/brightnessctl.c
index cbfe410..c0ffd0a 100644
--- a/brightnessctl.c
+++ b/brightnessctl.c
@@ -320,7 +320,7 @@ int read_device(struct device *d, char *class, char *id) {
d->id = strdup(id);
dev_path = device_path(d);
if (!(dirp = opendir(dev_path)))
- goto fail;
+ goto dfail;
while ((ent = readdir(dirp))) {
if (!strcmp(ent->d_name, ".") && !strcmp(ent->d_name, ".."))
continue;
@@ -356,6 +356,7 @@ int read_device(struct device *d, char *class, char *id) {
errno = 0;
fail:
closedir(dirp);
+dfail:
if (errno) {
perror("Error reading device");
error++;