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

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

Merge "diag: Cleanup client information on deinit Ioctl"

parents 14928271 218c2b4c
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -433,6 +433,7 @@ struct diagchar_dev {
	struct device *diag_dev;
	int ref_count;
	struct mutex diagchar_mutex;
	struct mutex diag_file_mutex;
	wait_queue_head_t wait_q;
	struct diag_client_map *client_map;
	int *data_ready;
+27 −8
Original line number Diff line number Diff line
@@ -443,20 +443,28 @@ static void diag_close_logging_process(int pid)

}

static int diagchar_close(struct inode *inode, struct file *file)
static int diag_remove_client_entry(struct file *file)
{
	int i = -1;
	struct diagchar_priv *diagpriv_data = file->private_data;
	struct diagchar_priv *diagpriv_data = NULL;
	struct diag_dci_client_tbl *dci_entry = NULL;

	pr_debug("diag: process exit %s\n", current->comm);
	if (!(file->private_data)) {
		pr_alert("diag: Invalid file pointer");
	if (!driver)
		return -ENOMEM;

	mutex_lock(&driver->diag_file_mutex);
	if (!file) {
		DIAG_LOG(DIAG_DEBUG_USERSPACE, "Invalid file pointer\n");
		mutex_unlock(&driver->diag_file_mutex);
		return -ENOENT;
	}
	if (!(file->private_data)) {
		DIAG_LOG(DIAG_DEBUG_USERSPACE, "Invalid private data\n");
		mutex_unlock(&driver->diag_file_mutex);
		return -EINVAL;
	}

	if (!driver)
		return -ENOMEM;
	diagpriv_data = file->private_data;

	/* clean up any DCI registrations, if this is a DCI client
	* This will specially help in case of ungraceful exit of any DCI client
@@ -482,12 +490,20 @@ static int diagchar_close(struct inode *inode, struct file *file)
			driver->client_map[i].pid = 0;
			kfree(diagpriv_data);
			diagpriv_data = NULL;
			file->private_data = 0;
			break;
		}
	}
	mutex_unlock(&driver->diagchar_mutex);
	mutex_unlock(&driver->diag_file_mutex);
	return 0;
}
static int diagchar_close(struct inode *inode, struct file *file)
{
	DIAG_LOG(DIAG_DEBUG_USERSPACE, "diag: process exit %s\n",
		current->comm);
	return diag_remove_client_entry(file);
}

void diag_record_stats(int type, int flag)
{
@@ -2399,7 +2415,9 @@ static ssize_t diagchar_read(struct file *file, char __user *buf, size_t count,
		data_type = driver->data_ready[index] & DEINIT_TYPE;
		COPY_USER_SPACE_OR_EXIT(buf, data_type, 4);
		driver->data_ready[index] ^= DEINIT_TYPE;
		goto exit;
		mutex_unlock(&driver->diagchar_mutex);
		diag_remove_client_entry(file);
		return ret;
	}

	if (driver->data_ready[index] & MSG_MASKS_TYPE) {
@@ -2945,6 +2963,7 @@ static int __init diagchar_init(void)
	non_hdlc_data.len = 0;
	mutex_init(&driver->hdlc_disable_mutex);
	mutex_init(&driver->diagchar_mutex);
	mutex_init(&driver->diag_file_mutex);
	mutex_init(&driver->delayed_rsp_mutex);
	mutex_init(&apps_data_mutex);
	init_waitqueue_head(&driver->wait_q);