Message ID | 20190527181050.GA31496@embeddedor (mailing list archive) |
---|---|
State | Mainlined |
Commit | 2649939ad750db48f94d3cdab26e3a0115672e6b |
Headers | show |
Series | usb: typec: ucsi: ccg: fix memory leak in do_flash | expand |
On Mon, May 27, 2019 at 01:10:50PM -0500, Gustavo A. R. Silva wrote: > In case memory resources for *fw* were successfully allocated, > release them before return. > > Addresses-Coverity-ID: 1445499 ("Resource leak") > Fixes: 5c9ae5a87573 ("usb: typec: ucsi: ccg: add firmware flashing support") > Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com> Acked-by: Heikki Krogerus <heikki.krogerus@gmail.com> > --- > drivers/usb/typec/ucsi/ucsi_ccg.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/drivers/usb/typec/ucsi/ucsi_ccg.c b/drivers/usb/typec/ucsi/ucsi_ccg.c > index 9d46aa9e4e35..bf63074675fc 100644 > --- a/drivers/usb/typec/ucsi/ucsi_ccg.c > +++ b/drivers/usb/typec/ucsi/ucsi_ccg.c > @@ -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) > -- > 2.21.0 thanks,
On Tue, May 28, 2019 at 11:04:52AM +0300, Heikki Krogerus wrote: > On Mon, May 27, 2019 at 01:10:50PM -0500, Gustavo A. R. Silva wrote: > > In case memory resources for *fw* were successfully allocated, > > release them before return. > > > > Addresses-Coverity-ID: 1445499 ("Resource leak") > > Fixes: 5c9ae5a87573 ("usb: typec: ucsi: ccg: add firmware flashing support") > > Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com> > > Acked-by: Heikki Krogerus <heikki.krogerus@gmail.com> That email address does not actually exist :-/. Sorry. Acked-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> > > --- > > drivers/usb/typec/ucsi/ucsi_ccg.c | 6 ++++-- > > 1 file changed, 4 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/usb/typec/ucsi/ucsi_ccg.c b/drivers/usb/typec/ucsi/ucsi_ccg.c > > index 9d46aa9e4e35..bf63074675fc 100644 > > --- a/drivers/usb/typec/ucsi/ucsi_ccg.c > > +++ b/drivers/usb/typec/ucsi/ucsi_ccg.c > > @@ -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) > > -- > > 2.21.0
diff --git a/drivers/usb/typec/ucsi/ucsi_ccg.c b/drivers/usb/typec/ucsi/ucsi_ccg.c index 9d46aa9e4e35..bf63074675fc 100644 --- a/drivers/usb/typec/ucsi/ucsi_ccg.c +++ b/drivers/usb/typec/ucsi/ucsi_ccg.c @@ -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)
In case memory resources for *fw* were successfully allocated, release them before return. Addresses-Coverity-ID: 1445499 ("Resource leak") Fixes: 5c9ae5a87573 ("usb: typec: ucsi: ccg: add firmware flashing support") Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com> --- drivers/usb/typec/ucsi/ucsi_ccg.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)