raw/ifpga/base: unlock mutex on Nios init failure
authorWei Huang <wei.huang@intel.com>
Thu, 5 Nov 2020 02:05:39 +0000 (21:05 -0500)
committerFerruh Yigit <ferruh.yigit@intel.com>
Fri, 13 Nov 2020 15:26:54 +0000 (16:26 +0100)
In fme_nios_spi_init(), a mutex is locked for protecting nios
initialization process, the mutex is only unlocked when process
is successful, it should also be unlocked when process fail.

Coverity issue: 363751
Fixes: e41856b515ce ("raw/ifpga/base: enhance driver reliability in multi-process")

Signed-off-by: Wei Huang <wei.huang@intel.com>
Acked-by: Rosen Xu <rosen.xu@intel.com>
drivers/raw/ifpga/base/ifpga_fme.c

index 540bb11..f29ff31 100644 (file)
@@ -1115,6 +1115,8 @@ static int fme_nios_spi_init(struct ifpga_feature *feature)
        ret = nios_spi_wait_init_done(spi_master);
        if (ret != 0) {
                dev_err(fme, "FME NIOS_SPI init fail\n");
+               if (spi_master->mutex)
+                       pthread_mutex_unlock(spi_master->mutex);
                goto release_dev;
        }