fpga manager: Fix firmware resource leak on error

If fpga_mgr_buf_load() fails, the firmware resource previously allocated
by request_firmware() is leaked. Fix it by calling release_firmware()
regardless of the return value of fpga_mgr_buf_load().

Found by the Coverity scanner (CID 1339653).

Fixes: 6a8c3be7ec ("add FPGA manager core")
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Acked-by: Alan Tull <atull@opensource.altera.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Tobias Klauser 2015-11-18 10:48:16 +01:00 committed by Greg Kroah-Hartman
parent 07687c031d
commit e8c77bda05
1 changed files with 1 additions and 3 deletions

View File

@ -122,12 +122,10 @@ int fpga_mgr_firmware_load(struct fpga_manager *mgr, u32 flags,
}
ret = fpga_mgr_buf_load(mgr, flags, fw->data, fw->size);
if (ret)
return ret;
release_firmware(fw);
return 0;
return ret;
}
EXPORT_SYMBOL_GPL(fpga_mgr_firmware_load);