summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Bradford <rob@linux.intel.com>2012-10-09 18:44:36 +0100
committerKristian Høgsberg <krh@bitplanet.net>2012-10-09 22:57:10 -0400
commita6b63d0f672e4215aac4ab2d32d82e0132d3165c (patch)
treeb7bf67325ae65cc69a9aee209c110c5bf6ab8525
parent6b6795f07070d08f1a26ceec146b91b841cb5654 (diff)
backlight: Jump to cleanup code if synthesizing backlight string fails
This applies the same pattern as used in other error cases in this block - and cleans up the file desciptors and allocated memory too. Signed-off-by: Rob Bradford <rob@linux.intel.com>
-rw-r--r--src/libbacklight.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/libbacklight.c b/src/libbacklight.c
index c432c6e5..df811b41 100644
--- a/src/libbacklight.c
+++ b/src/libbacklight.c
@@ -111,8 +111,10 @@ long backlight_set_brightness(struct backlight *backlight, long brightness)
goto out;
}
- if (asprintf(&buffer, "%ld", brightness) < 0)
- return -ENOMEM;
+ if (asprintf(&buffer, "%ld", brightness) < 0) {
+ ret = -1;
+ goto out;
+ }
ret = write(fd, buffer, strlen(buffer));
if (ret < 0) {