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

Commit 8f5b0629 authored by Hardik Arya's avatar Hardik Arya
Browse files

soc: qcom: glink_pkt: Try allocation with vmalloc



Glink_pkt driver try to allocate the tx buffer with kmalloc
which can fail for higher order allocations. This leads to failure
of client's transaction.

Glink_pkt driver uses vmalloc in case of failure with kmalloc.

Change-Id: I24a1ae56852d7c043552f5c4c6cc20bf4cfaebcf
Signed-off-by: default avatarHardik Arya <harya@codeaurora.org>
parent 38bc3d98
Loading
Loading
Loading
Loading
+10 −7
Original line number Diff line number Diff line
/* Copyright (c) 2014-2017, The Linux Foundation. All rights reserved.
/* Copyright (c) 2014-2018, 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
@@ -29,6 +29,7 @@
#include <asm/ioctls.h>
#include <linux/mm.h>
#include <linux/of.h>
#include <linux/vmalloc.h>
#include <linux/ipc_logging.h>
#include <linux/termios.h>

@@ -399,7 +400,7 @@ void glink_pkt_notify_tx_done(void *handle, const void *priv,
	GLINK_PKT_INFO("%s(): priv[%p] pkt_priv[%p] ptr[%p]\n",
					__func__, priv, pkt_priv, ptr);
	/* Free Tx buffer allocated in glink_pkt_write */
	kfree(ptr);
	kvfree(ptr);
}

/**
@@ -774,7 +775,9 @@ ssize_t glink_pkt_write(struct file *file,
		__func__, devp->i, count);
	data = kzalloc(count, GFP_KERNEL);
	if (!data) {
		GLINK_PKT_ERR("%s buffer allocation failed\n", __func__);
		if (!strcmp(devp->open_cfg.edge, "bg"))
			data = vzalloc(count);
		if (!data)
			return -ENOMEM;
	}

@@ -783,14 +786,14 @@ ssize_t glink_pkt_write(struct file *file,
		GLINK_PKT_ERR(
		"%s copy_from_user failed ret[%d] on dev id:%d size %zu\n",
		 __func__, ret, devp->i, count);
		kfree(data);
		kvfree(data);
		return -EFAULT;
	}

	ret = glink_tx(devp->handle, data, data, count, GLINK_TX_REQ_INTENT);
	if (ret) {
		GLINK_PKT_ERR("%s glink_tx failed ret[%d]\n", __func__, ret);
		kfree(data);
		kvfree(data);
		return ret;
	}