jail: netifd: fix error handling issue reported by coverity
authorDaniel Golle <daniel@makrotopia.org>
Sat, 16 Oct 2021 23:29:08 +0000 (00:29 +0100)
committerDaniel Golle <daniel@makrotopia.org>
Sun, 17 Oct 2021 18:33:51 +0000 (19:33 +0100)
Check asprintf return value instead of checking for NULL-pointer.

Coverity CID: 1492158 Unchecked return value
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
jail/netifd.c

index 6096cfc4ac7bf6edae36fd069cbadb25e1d51246..f6f2df679451da9d34be824a106de4bf5a795424 100644 (file)
@@ -425,14 +425,12 @@ int jail_network_start(struct ubus_context *new_ctx, char *new_jail_name, pid_t
        ns_pid = new_ns_pid;
        jail_name = new_jail_name;
 
-       asprintf(&ubus_sock_dir, "/var/containers/ubus-%s", jail_name);
-       if (!ubus_sock_dir) {
+       if (asprintf(&ubus_sock_dir, "/var/containers/ubus-%s", jail_name) == -1) {
                ret = ENOMEM;
                goto errout_dir;
        }
 
-       asprintf(&ubus_sock_path, "%s/ubus", ubus_sock_dir);
-       if (!ubus_sock_path) {
+       if (asprintf(&ubus_sock_path, "%s/ubus", ubus_sock_dir) == -1) {
                ret = ENOMEM;
                goto errout_path;
        }