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

Commit bb54209c authored by Armaan Siddiqui's avatar Armaan Siddiqui Committed by Gerrit - the friendly Code Review server
Browse files

msm: gsi: Using kzalloc instead of devm_kzalloc



devm_kzalloc causes memory failure, so using kzalloc
to avoid memory allocation failure.

Change-Id: I85befc8c2b06ce74419e4e508fc982ff4df5a343
Signed-off-by: default avatarArmaan Siddiqui <asiddiqu@codeaurora.org>
parent 4bf3c1bd
Loading
Loading
Loading
Loading
+8 −8
Original line number Diff line number Diff line
/* Copyright (c) 2015-2018, The Linux Foundation. All rights reserved.
/* Copyright (c) 2015-2018, 2021, 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
@@ -18,6 +18,7 @@
#include <linux/msm_gsi.h>
#include <linux/platform_device.h>
#include <linux/delay.h>
#include <linux/slab.h>
#include "gsi.h"
#include "gsi_reg.h"

@@ -1605,7 +1606,7 @@ int gsi_alloc_channel(struct gsi_chan_props *props, unsigned long dev_hdl,
{
	struct gsi_chan_ctx *ctx;
	uint32_t val;
	int res;
	int res, size;
	int ee;
	enum gsi_ch_cmd_opcode op = GSI_CH_ALLOCATE;
	uint8_t erindex;
@@ -1650,9 +1651,8 @@ int gsi_alloc_channel(struct gsi_chan_props *props, unsigned long dev_hdl,
	}

	memset(ctx, 0, sizeof(*ctx));
	user_data = devm_kzalloc(gsi_ctx->dev,
		(props->ring_len / props->re_size) * sizeof(void *),
		GFP_KERNEL);
	size = (props->ring_len / props->re_size) * sizeof(void *);
	user_data = kzalloc(size, GFP_KERNEL);
	if (user_data == NULL) {
		GSIERR("%s:%d gsi context not allocated\n", __func__, __LINE__);
		return -GSI_STATUS_RES_ALLOC_FAILURE;
@@ -1675,14 +1675,14 @@ int gsi_alloc_channel(struct gsi_chan_props *props, unsigned long dev_hdl,
	if (res == 0) {
		GSIERR("chan_hdl=%u timed out\n", props->ch_id);
		mutex_unlock(&gsi_ctx->mlock);
		devm_kfree(gsi_ctx->dev, user_data);
		kfree(user_data);
		return -GSI_STATUS_TIMED_OUT;
	}
	if (ctx->state != GSI_CHAN_STATE_ALLOCATED) {
		GSIERR("chan_hdl=%u allocation failed state=%d\n",
				props->ch_id, ctx->state);
		mutex_unlock(&gsi_ctx->mlock);
		devm_kfree(gsi_ctx->dev, user_data);
		kfree(user_data);
		return -GSI_STATUS_RES_ALLOC_FAILURE;
	}
	mutex_unlock(&gsi_ctx->mlock);
@@ -2129,7 +2129,7 @@ int gsi_dealloc_channel(unsigned long chan_hdl)

	mutex_unlock(&gsi_ctx->mlock);

	devm_kfree(gsi_ctx->dev, ctx->user_data);
	kfree(ctx->user_data);
	ctx->allocated = false;
	if (ctx->evtr)
		atomic_dec(&ctx->evtr->chan_ref_cnt);