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

Commit 50745e47 authored by Sreelakshmi Gownipalli's avatar Sreelakshmi Gownipalli Committed by Bernhard Thoben
Browse files

diag: Protect the decrement of number of diag clients



In diagchar_open() protect the decrement of number of diag clients
so that there will be no race conditions while reading the value
from other functions.

Bug: 79421261
Change-Id: I0e2fb5331eec9c7bba39e7d881b69559256833a3
Signed-off-by: default avatarSreelakshmi Gownipalli <sgownipa@codeaurora.org>
(cherry picked from commit eb2a2fb1584f0d6338902d375f1d3838a124799f)
parent 01059ed0
Loading
Loading
Loading
Loading
+4 −7
Original line number Original line Diff line number Diff line
/* Copyright (c) 2008-2016, The Linux Foundation. All rights reserved.
/* Copyright (c) 2008-2015, 2017-2018 The Linux Foundation.
 * All rights reserved.
 *
 *
 * This program is free software; you can redistribute it and/or modify
 * 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
 * it under the terms of the GNU General Public License version 2 and
@@ -322,9 +323,9 @@ static int diagchar_open(struct inode *inode, struct file *file)
	return -ENOMEM;
	return -ENOMEM;


fail:
fail:
	mutex_unlock(&driver->diagchar_mutex);
	driver->num_clients--;
	driver->num_clients--;
	pr_alert("diag: Insufficient memory for new client");
	mutex_unlock(&driver->diagchar_mutex);
	pr_err_ratelimited("diag: Insufficient memory for new client");
	return -ENOMEM;
	return -ENOMEM;
}
}


@@ -1269,10 +1270,6 @@ long diagchar_compat_ioctl(struct file *filp,
		dci_client = diag_dci_get_client_entry(client_id);
		dci_client = diag_dci_get_client_entry(client_id);
		if (!dci_client)
		if (!dci_client)
			return DIAG_DCI_NOT_SUPPORTED;
			return DIAG_DCI_NOT_SUPPORTED;
<<<<<<< HEAD
=======
		}
>>>>>>> 1ede4694d5b2 (diag: Fix for possible dci stale entries)
		result = diag_dci_deinit_client(dci_client);
		result = diag_dci_deinit_client(dci_client);
		mutex_unlock(&driver->dci_mutex);
		mutex_unlock(&driver->dci_mutex);
		break;
		break;