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

Commit 841cf03d authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "diag: Add protection while accessing usb_info's buffer table"

parents 168a91f8 6f1987e5
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -311,23 +311,25 @@ static void diag_usb_write_done(struct diag_usb_info *ch,
	if (!ch || !req)
		return;

	spin_lock_irqsave(&ch->write_lock, flags);
	ch->write_cnt++;
	entry = diag_usb_buf_tbl_get(ch, req->context);
	if (!entry) {
		pr_err_ratelimited("diag: In %s, unable to find entry %pK in the table\n",
				   __func__, req->context);
		spin_unlock_irqrestore(&ch->write_lock, flags);
		return;
	}
	if (atomic_read(&entry->ref_count) != 0) {
		DIAG_LOG(DIAG_DEBUG_MUX, "partial write_done ref %d\n",
			 atomic_read(&entry->ref_count));
		diag_ws_on_copy_complete(DIAG_WS_MUX);
		spin_unlock_irqrestore(&ch->write_lock, flags);
		diagmem_free(driver, req, ch->mempool);
		return;
	}
	DIAG_LOG(DIAG_DEBUG_MUX, "full write_done, ctxt: %d\n",
		 ctxt);
	spin_lock_irqsave(&ch->write_lock, flags);
	list_del(&entry->track);
	ctxt = entry->ctxt;
	buf = entry->buf;