Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fe490465 authored by Hardik Arya's avatar Hardik Arya
Browse files

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: default avatarHardik Arya <harya@codeaurora.org>
parent c0690fe0
Loading
Loading
Loading
Loading
+5 −1
Original line number Original line Diff line number Diff line
@@ -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
			 * Remove reference from the table if it is the
			 * only instance of the buffer
			 * only instance of the buffer
			 */
			 */
			if (atomic_read(&entry->ref_count) == 0)
			if (atomic_read(&entry->ref_count) == 0) {
				list_del(&entry->track);
				list_del(&entry->track);
				kfree(entry);
				entry = NULL;
			}
			break;
			break;
		}
		}
	}
	}
@@ -330,6 +333,7 @@ static void diag_usb_write_done(struct diag_usb_info *ch,
	buf = entry->buf;
	buf = entry->buf;
	len = entry->len;
	len = entry->len;
	kfree(entry);
	kfree(entry);
	entry = NULL;
	diag_ws_on_copy_complete(DIAG_WS_MUX);
	diag_ws_on_copy_complete(DIAG_WS_MUX);


	if (ch->ops && ch->ops->write_done)
	if (ch->ops && ch->ops->write_done)