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

Commit 922e6364 authored by Naresh Maradana's avatar Naresh Maradana
Browse files

seemp: update to seemp_logk_set_mapping()



Updating/interchanging the code in the Lock section
to avoid memory leak in race condition
in function seemp_logk_set_mapping().

Change-Id: I93fba54444c463f18faf1a2aa8be858a29d94a1b
Signed-off-by: default avatarNaresh Maradana <nmardana@codeaurora.org>
parent ad957023
Loading
Loading
Loading
Loading
+12 −14
Original line number Diff line number Diff line
@@ -472,20 +472,6 @@ static long seemp_logk_set_mapping(unsigned long arg)
		(UINT_MAX / sizeof(struct seemp_source_mask))))
		return -EFAULT;

	write_lock(&filter_lock);
	if (pmask != NULL) {
		/*
		 * Mask is getting set again.
		 * seemp_core was probably restarted.
		 */
		struct seemp_source_mask *ptempmask;

		num_sources = 0;
		ptempmask = pmask;
		pmask = NULL;
		kfree(ptempmask);
	}
	write_unlock(&filter_lock);
	pbuffer = kmalloc_array(num_elements,
				sizeof(struct seemp_source_mask), GFP_KERNEL);
	if (pbuffer == NULL)
@@ -511,6 +497,18 @@ static long seemp_logk_set_mapping(unsigned long arg)
		pnewmask[i].isOn = 0;
	}
	write_lock(&filter_lock);
	if (pmask != NULL) {
		/*
		 * Mask is getting set again.
		 * seemp_core was probably restarted.
		 */
		struct seemp_source_mask *ptempmask;

		num_sources = 0;
		ptempmask = pmask;
		pmask = NULL;
		kfree(ptempmask);
	}
	pmask = pnewmask;
	num_sources = num_elements;
	write_unlock(&filter_lock);