diff options
author | Hardik Arya <harya@codeaurora.org> | 2018-04-16 16:46:58 +0530 |
---|---|---|
committer | Gerrit - the friendly Code Review server <code-review@localhost> | 2019-03-25 01:44:15 -0700 |
commit | 875833b037e18d1189afb5fe000072488c866260 (patch) | |
tree | d14974d8ea276686df56be48188e0aeab925ebfb /drivers | |
parent | e764712fd7f6db7921dc4b3dbbf772d613177633 (diff) |
diag: Free usb buffer's entry after removing from list
Currently, there is possibility of memory leak due to not
freeing allocated memory for usb buffer's entry after
removing it from list. The patch handle this by freeing
the entry.
Change-Id: Idb08ecad859749e6ab1b09184362de38de4a9836
Signed-off-by: Hardik Arya <harya@codeaurora.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/char/diag/diag_usb.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/drivers/char/diag/diag_usb.c b/drivers/char/diag/diag_usb.c index d80f0b1cfde1..4dcc0a5727d0 100644 --- a/drivers/char/diag/diag_usb.c +++ b/drivers/char/diag/diag_usb.c @@ -139,8 +139,11 @@ static void diag_usb_buf_tbl_remove(struct diag_usb_info *usb_info, * Remove reference from the table if it is the * only instance of the buffer */ - if (atomic_read(&entry->ref_count) == 0) + if (atomic_read(&entry->ref_count) == 0) { list_del(&entry->track); + kfree(entry); + entry = NULL; + } break; } } @@ -331,6 +334,7 @@ static void diag_usb_write_done(struct diag_usb_info *ch, buf = entry->buf; len = entry->len; kfree(entry); + entry = NULL; diag_ws_on_copy_complete(DIAG_WS_MUX); if (ch->ops && ch->ops->write_done) |