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

Commit b4a235f5 authored by Sreelakshmi Gownipalli's avatar Sreelakshmi Gownipalli Committed by Manoj Prabhu B
Browse files

diag: Protect memory allocation in diagfwd_mhi_read_work_fn



Protect the memory allocation with mhi channel lock in
diagfwd_read_work_fn() to avoid race condition while
freeing up the memory.

Change-Id: I3c06da2bdf649c7ef67864ce68d5cca1d91eff8e
Signed-off-by: default avatarSreelakshmi Gownipalli <sgownipa@codeaurora.org>
Signed-off-by: default avatarManoj Prabhu B <bmanoj@codeaurora.org>
parent 9b0f7eab
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
/* Copyright (c) 2014-2017, The Linux Foundation. All rights reserved.
/* Copyright (c) 2014-2018, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -434,9 +434,10 @@ static void mhi_read_work_fn(struct work_struct *work)
	do {
		if (!(atomic_read(&(read_ch->opened))))
			break;

		spin_lock_irqsave(&read_ch->lock, flags);
		buf = diagmem_alloc(driver, DIAG_MDM_BUF_SIZE,
				    mhi_info->mempool);
		spin_unlock_irqrestore(&read_ch->lock, flags);
		if (!buf)
			break;

@@ -743,4 +744,3 @@ void diag_mhi_exit(void)
			diagmem_exit(driver, mhi_info->mempool);
	}
}