From: Yu Watanabe Date: Thu, 18 Feb 2021 14:40:33 +0000 (+0900) Subject: sd-device: the last argument of sd_device_get_sysattr_value() may be NULL X-Git-Tag: v248-rc1~19^2~15 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=32a739afe0c14fab00cfe45dfe87e60d59c74ce0;p=thirdparty%2Fsystemd.git sd-device: the last argument of sd_device_get_sysattr_value() may be NULL --- diff --git a/src/libsystemd/sd-device/sd-device.c b/src/libsystemd/sd-device/sd-device.c index 5e161ec03ff..991779aa9c1 100644 --- a/src/libsystemd/sd-device/sd-device.c +++ b/src/libsystemd/sd-device/sd-device.c @@ -1862,7 +1862,7 @@ static int device_get_cached_sysattr_value(sd_device *device, const char *_key, /* We cache all sysattr lookups. If an attribute does not exist, it is stored * with a NULL value in the cache, otherwise the returned string is stored */ -_public_ int sd_device_get_sysattr_value(sd_device *device, const char *sysattr, const char **_value) { +_public_ int sd_device_get_sysattr_value(sd_device *device, const char *sysattr, const char **ret_value) { _cleanup_free_ char *value = NULL; const char *path, *syspath, *cached_value = NULL; struct stat statbuf; @@ -1881,8 +1881,8 @@ _public_ int sd_device_get_sysattr_value(sd_device *device, const char *sysattr, /* we looked up the sysattr before and it did not exist */ return -ENOENT; - if (_value) - *_value = cached_value; + if (ret_value) + *ret_value = cached_value; return 0; } @@ -1929,7 +1929,8 @@ _public_ int sd_device_get_sysattr_value(sd_device *device, const char *sysattr, if (r < 0) return r; - *_value = TAKE_PTR(value); + if (ret_value) + *ret_value = TAKE_PTR(value); return 0; }