diff options
Diffstat (limited to 'drivers/base/firmware_loader')
-rw-r--r-- | drivers/base/firmware_loader/main.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/drivers/base/firmware_loader/main.c b/drivers/base/firmware_loader/main.c index c8966c84bd44..f5046887e362 100644 --- a/drivers/base/firmware_loader/main.c +++ b/drivers/base/firmware_loader/main.c @@ -403,7 +403,7 @@ static int fw_add_devm_name(struct device *dev, const char *name) fwn = fw_find_devm_name(dev, name); if (fwn) - return 1; + return 0; fwn = devres_alloc(fw_name_devm_release, sizeof(struct fw_name_devm), GFP_KERNEL); @@ -431,6 +431,7 @@ int assign_fw(struct firmware *fw, struct device *device, unsigned int opt_flags) { struct fw_priv *fw_priv = fw->priv; + int ret; mutex_lock(&fw_lock); if (!fw_priv->size || fw_state_is_aborted(fw_priv)) { @@ -447,8 +448,13 @@ int assign_fw(struct firmware *fw, struct device *device, */ /* don't cache firmware handled without uevent */ if (device && (opt_flags & FW_OPT_UEVENT) && - !(opt_flags & FW_OPT_NOCACHE)) - fw_add_devm_name(device, fw_priv->fw_name); + !(opt_flags & FW_OPT_NOCACHE)) { + ret = fw_add_devm_name(device, fw_priv->fw_name); + if (ret) { + mutex_unlock(&fw_lock); + return ret; + } + } /* * After caching firmware image is started, let it piggyback |