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

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

Merge "msm: kgsl: Fix kgsl memory allocation and free race condition"

parents 8073a40a e916f517
Loading
Loading
Loading
Loading
+14 −2
Original line number Diff line number Diff line
/* Copyright (c) 2008-2016, The Linux Foundation. All rights reserved.
/* Copyright (c) 2008-2017, 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
@@ -209,8 +209,11 @@ kgsl_mem_entry_create(void)
{
	struct kgsl_mem_entry *entry = kzalloc(sizeof(*entry), GFP_KERNEL);

	if (entry)
	if (entry) {
		kref_init(&entry->refcount);
		/* put this ref in the caller functions after init */
		kref_get(&entry->refcount);
	}

	return entry;
}
@@ -3259,6 +3262,9 @@ long kgsl_ioctl_map_user_mem(struct kgsl_device_private *dev_priv,
	trace_kgsl_mem_map(entry, param->fd);

	kgsl_mem_entry_commit_process(private, entry);

	/* put the extra refcount for kgsl_mem_entry_create() */
	kgsl_mem_entry_put(entry);
	return result;

error_attach:
@@ -3603,6 +3609,9 @@ long kgsl_ioctl_gpumem_alloc(struct kgsl_device_private *dev_priv,
	param->flags = entry->memdesc.flags;

	kgsl_mem_entry_commit_process(private, entry);

	/* put the extra refcount for kgsl_mem_entry_create() */
	kgsl_mem_entry_put(entry);
	return result;
err:
	kgsl_sharedmem_free(&entry->memdesc);
@@ -3645,6 +3654,9 @@ long kgsl_ioctl_gpumem_alloc_id(struct kgsl_device_private *dev_priv,
	param->gpuaddr = entry->memdesc.gpuaddr;

	kgsl_mem_entry_commit_process(private, entry);

	/* put the extra refcount for kgsl_mem_entry_create() */
	kgsl_mem_entry_put(entry);
	return result;
err:
	if (entry)