pch_phub: return -ENODATA if ROM can't be mapped
authorColin Ian King <colin.king@canonical.com>
Sat, 27 Feb 2016 14:52:22 +0000 (14:52 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 5 Mar 2016 20:19:39 +0000 (12:19 -0800)
The error return err is not initialized for the case when pci_map_rom
fails and no ROM can me mapped.  Fix this by setting ret to -ENODATA;
(this is the same error value that is returned if the ROM data is
successfully mapped but does not match the expected ROM signature.).

Issue found from static code analysis using CoverityScan.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/misc/pch_phub.c

index 15bb0c8cdda38b1b788993a78a68196a22c8f74b..4810e039bbeced8bd7bb337ddd6404c95b3bfdd6 100644 (file)
@@ -513,8 +513,10 @@ static ssize_t pch_phub_bin_read(struct file *filp, struct kobject *kobj,
 
        /* Get Rom signature */
        chip->pch_phub_extrom_base_address = pci_map_rom(chip->pdev, &rom_size);
-       if (!chip->pch_phub_extrom_base_address)
+       if (!chip->pch_phub_extrom_base_address) {
+               err = -ENODATA;
                goto exrom_map_err;
+       }
 
        pch_phub_read_serial_rom(chip, chip->pch_opt_rom_start_address,
                                (unsigned char *)&rom_signature);