2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2024-12-25 13:43:55 +08:00

usb: typec: ucsi: ccg: fix memory leak in do_flash

In case memory resources for *fw* were successfully allocated,
release them before return.

Addresses-Coverity-ID: 1445499 ("Resource leak")
Fixes: 5c9ae5a875 ("usb: typec: ucsi: ccg: add firmware flashing support")
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Acked-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Gustavo A. R. Silva 2019-05-27 13:10:50 -05:00 committed by Greg Kroah-Hartman
parent f2c7c76c5d
commit 2649939ad7

View File

@ -862,8 +862,10 @@ static int do_flash(struct ucsi_ccg *uc, enum enum_flash_mode mode)
not_signed_fw:
wr_buf = kzalloc(CCG4_ROW_SIZE + 4, GFP_KERNEL);
if (!wr_buf)
return -ENOMEM;
if (!wr_buf) {
err = -ENOMEM;
goto release_fw;
}
err = ccg_cmd_enter_flashing(uc);
if (err)