]> git.ozlabs.org Git - petitboot/commitdiff
discover: Properly handle return values
authorSamuel Mendoza-Jonas <sam.mj@au1.ibm.com>
Mon, 9 Nov 2015 03:45:58 +0000 (14:45 +1100)
committerSamuel Mendoza-Jonas <sam.mj@au1.ibm.com>
Thu, 17 Dec 2015 03:51:46 +0000 (14:51 +1100)
Fixes three unchecked return values, and one missing
initialisation.
Fixes Coverity defects #30450, #30451, #30454, and #30483

Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
discover/device-handler.c
discover/ipmi.c
discover/paths.c
discover/platform-powerpc.c

index bfe5fffe033dac37b6d06c16886dc078e063d54e..3804b34da08fcf781438db1abfaf04205c4cc373 100644 (file)
@@ -1472,7 +1472,6 @@ mount_ro:
 void device_release_write(struct discover_device *dev, bool release)
 {
        const char *fstype, *device_path;
 void device_release_write(struct discover_device *dev, bool release)
 {
        const char *fstype, *device_path;
-       int rc = 0;
 
        if (!release)
                return;
 
        if (!release)
                return;
@@ -1495,10 +1494,9 @@ void device_release_write(struct discover_device *dev, bool release)
                device_path = get_device_path(dev);
        }
 
                device_path = get_device_path(dev);
        }
 
-       mount(device_path, dev->mount_path, fstype,
+       if (mount(device_path, dev->mount_path, fstype,
                        MS_RDONLY | MS_SILENT,
                        MS_RDONLY | MS_SILENT,
-                       fs_parameters(dev, MS_RDONLY));
-       if (rc)
+                       fs_parameters(dev, MS_RDONLY)))
                pb_log("Failed to remount %s read-only: %s\n",
                       device_path, strerror(errno));
        else
                pb_log("Failed to remount %s read-only: %s\n",
                       device_path, strerror(errno));
        else
index 54d4e0636f37093b089fc4a7748ca9e7db8533d4..f59974aaf637b623a413e890177bee9b0dc39a77 100644 (file)
@@ -183,7 +183,8 @@ int ipmi_transaction(struct ipmi *ipmi, uint8_t netfn, uint8_t cmd,
 
 out:
        lock.l_type = F_UNLCK;
 
 out:
        lock.l_type = F_UNLCK;
-       fcntl(ipmi->fd, F_SETLKW, &lock);
+       if (fcntl(ipmi->fd, F_SETLKW, &lock) == -1)
+               pb_log("IPMI: error unlocking IPMI device: %m\n");
        return rc ? -1 : 0;
 }
 
        return rc ? -1 : 0;
 }
 
index 0d414ebaac0833a075b0f65532734e1620e46649..c25671b17a6a22404600da2a64cc9febca93f84f 100644 (file)
@@ -220,15 +220,16 @@ static enum tftp_type check_tftp_type(void *ctx)
        const char *argv[] = { pb_system_apps.tftp, "-V", NULL };
        struct process *process;
        enum tftp_type type;
        const char *argv[] = { pb_system_apps.tftp, "-V", NULL };
        struct process *process;
        enum tftp_type type;
+       int rc;
 
        process = process_create(ctx);
        process->path = pb_system_apps.tftp;
        process->argv = argv;
        process->keep_stdout = true;
        process->add_stderr = true;
 
        process = process_create(ctx);
        process->path = pb_system_apps.tftp;
        process->argv = argv;
        process->keep_stdout = true;
        process->add_stderr = true;
-       process_run_sync(process);
+       rc = process_run_sync(process);
 
 
-       if (!process->stdout_buf || process->stdout_len == 0) {
+       if (rc || !process->stdout_buf || process->stdout_len == 0) {
                pb_log("Can't check TFTP client type!\n");
                type = TFTP_TYPE_BROKEN;
 
                pb_log("Can't check TFTP client type!\n");
                type = TFTP_TYPE_BROKEN;
 
index 280793425198a483ecea8c1e4217b9844728d842..ce4eb8199ed33d01570e14aac57ce924fba3bb90 100644 (file)
@@ -179,7 +179,7 @@ static int write_nvram(struct platform_powerpc *platform)
        struct process *process;
        struct param *param;
        const char *argv[6];
        struct process *process;
        struct param *param;
        const char *argv[6];
-       int rc;
+       int rc = 0;
 
        argv[0] = "nvram";
        argv[1] = "--update-config";
 
        argv[0] = "nvram";
        argv[1] = "--update-config";