From: Florian Fainelli Date: Sat, 3 Dec 2016 17:32:21 +0000 (-0800) Subject: hotplug: Check chown return value X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=e999ab7e5ab5f8284f2987f7e1e0b9b7a63c4761;p=oweals%2Fprocd.git hotplug: Check chown return value Fixes: plug/hotplug.c:152:10: error: ignoring return value of 'chown', declared with attribute warn_unused_result [-Werror=unused-result] chown(blobmsg_get_string(tb[0]), 0, g->gr_gid); Signed-off-by: Florian Fainelli --- diff --git a/plug/hotplug.c b/plug/hotplug.c index 8595915..54a90cc 100644 --- a/plug/hotplug.c +++ b/plug/hotplug.c @@ -130,6 +130,7 @@ static void handle_makedev(struct blob_attr *msg, struct blob_attr *data) char *minor = hotplug_msg_find_var(msg, "MINOR"); char *major = hotplug_msg_find_var(msg, "MAJOR"); char *subsystem = hotplug_msg_find_var(msg, "SUBSYSTEM"); + int ret; blobmsg_parse_array(mkdev_policy, 3, tb, blobmsg_data(data), blobmsg_data_len(data)); if (tb[0] && tb[1] && minor && major && subsystem) { @@ -149,8 +150,9 @@ static void handle_makedev(struct blob_attr *msg, struct blob_attr *data) struct group *g = getgrnam(blobmsg_get_string(tb[2])); if (g) - chown(blobmsg_get_string(tb[0]), 0, g->gr_gid); - else + ret = chown(blobmsg_get_string(tb[0]), 0, g->gr_gid); + + if (!g || ret < 0) ERROR("cannot set group %s for %s\n", blobmsg_get_string(tb[2]), blobmsg_get_string(tb[0]));