fpga: m10bmc-sec: Fix possible memory leak of flash_buf
authorRuss Weight <russell.h.weight@intel.com>
Fri, 16 Sep 2022 23:52:05 +0000 (16:52 -0700)
committerXu Yilun <yilun.xu@intel.com>
Mon, 19 Sep 2022 04:58:19 +0000 (12:58 +0800)
commit468c9d928a8f38fdfaa61b05e81473cc7c8a6461
tree30b029aeee697f8fd140e90c3d28a1c021ea9340
parent568035b01cfb107af8d2e4bd2fb9aea22cf5b868
fpga: m10bmc-sec: Fix possible memory leak of flash_buf

There is an error check following the allocation of flash_buf that returns
without freeing flash_buf. It makes more sense to do the error check
before the allocation and the reordering eliminates the memory leak.

Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Fixes: 154afa5c31cd ("fpga: m10bmc-sec: expose max10 flash update count")
Signed-off-by: Russ Weight <russell.h.weight@intel.com>
Reviewed-by: Tom Rix <trix@redhat.com>
Acked-by: Xu Yilun <yilun.xu@intel.com>
Cc: <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20220916235205.106873-1-russell.h.weight@intel.com
Signed-off-by: Xu Yilun <yilun.xu@intel.com>
drivers/fpga/intel-m10-bmc-sec-update.c