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

Commit d6b6d0a2 authored by Puranam V G Tejaswi's avatar Puranam V G Tejaswi
Browse files

msm: kgsl: Fix invalid pointer reference at a few places



kgsl_allocate_global can fail for global buffer profile_desc. Hence make
sure that an invalid access to the pointer is not made in
set_user_profiling. Similarly allocations for global buffers setstate and
alwayson can also fail. Make sure we don't access an invalid pointer in
adreno_snapshot_global and kgsl_gpuaddr_in_memdesc.

Change-Id: Ia2f314575c5f4357ac8f7a2a72e869e3c648837d
Signed-off-by: default avatarPuranam V G Tejaswi <pvgtejas@codeaurora.org>
parent bb168a0f
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (c) 2002,2007-2020, The Linux Foundation. All rights reserved.
 * Copyright (c) 2002,2007-2021, The Linux Foundation. All rights reserved.
 */

#include <linux/interconnect.h>
@@ -837,7 +837,7 @@ static int set_user_profiling(struct adreno_device *adreno_dev,
	u64 ib_gpuaddr;
	u32 *ib;

	if (!rb->profile_desc->hostptr)
	if (IS_ERR(rb->profile_desc))
		return 0;

	ib = ((u32 *) rb->profile_desc->hostptr) +
+2 −2
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (c) 2012-2020, The Linux Foundation. All rights reserved.
 * Copyright (c) 2012-2021, The Linux Foundation. All rights reserved.
 */

#include "adreno.h"
@@ -746,7 +746,7 @@ size_t adreno_snapshot_global(struct kgsl_device *device, u8 *buf,

	u8 *ptr = buf + sizeof(*header);

	if (!memdesc || memdesc->size == 0)
	if (IS_ERR_OR_NULL(memdesc) || memdesc->size == 0)
		return 0;

	if (remain < (memdesc->size + sizeof(*header))) {
+2 −2
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0-only */
/*
 * Copyright (c) 2008-2020, The Linux Foundation. All rights reserved.
 * Copyright (c) 2008-2021, The Linux Foundation. All rights reserved.
 */
#ifndef __KGSL_H
#define __KGSL_H
@@ -479,7 +479,7 @@ void kgsl_core_exit(void);
static inline bool kgsl_gpuaddr_in_memdesc(const struct kgsl_memdesc *memdesc,
				uint64_t gpuaddr, uint64_t size)
{
	if (!memdesc)
	if (IS_ERR_OR_NULL(memdesc))
		return false;

	/* set a minimum size to search for */