Commit e8c77bda05e5d93cce6f38cfdde4192307951dea

Authored by Tobias Klauser
Committed by Greg Kroah-Hartman
1 parent 07687c031d

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: 6a8c3be7ec8e ("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>

Showing 1 changed file with 1 additions and 3 deletions Side-by-side Diff

drivers/fpga/fpga-mgr.c
... ... @@ -122,12 +122,10 @@
122 122 }
123 123  
124 124 ret = fpga_mgr_buf_load(mgr, flags, fw->data, fw->size);
125   - if (ret)
126   - return ret;
127 125  
128 126 release_firmware(fw);
129 127  
130   - return 0;
  128 + return ret;
131 129 }
132 130 EXPORT_SYMBOL_GPL(fpga_mgr_firmware_load);
133 131