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

Commit 2212b27c authored by Dhoat Harpal's avatar Dhoat Harpal Committed by Chris Lew
Browse files

soc: qcom: glink_pkt: Remove WARN_ON in glink_pkt_write



WARN_ON is called when error is returned from copy_from_user and
copy_to_user apis.

WARN_ON is removed and appropriate error value is returned after cleanup.

CRs-Fixed: 1102504
Change-Id: Ia995e60b8d8d335239be0a35876d1becfd9a0f3c
Signed-off-by: default avatarDhoat Harpal <hdhoat@codeaurora.org>
parent 6862ebda
Loading
Loading
Loading
Loading
+17 −5
Original line number Diff line number Diff line
/* Copyright (c) 2014-2016, The Linux Foundation. All rights reserved.
/* Copyright (c) 2014-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
@@ -664,8 +664,15 @@ ssize_t glink_pkt_read(struct file *file,
	spin_unlock_irqrestore(&devp->pkt_list_lock, flags);

	ret = copy_to_user(buf, pkt->data, pkt->size);
	if (WARN_ON(ret != 0))
		return ret;
	if (ret) {
		GLINK_PKT_ERR(
		"%s copy_to_user failed ret[%d] on dev id:%d size %zu\n",
		 __func__, ret, devp->i, pkt->size);
		spin_lock_irqsave(&devp->pkt_list_lock, flags);
		list_add_tail(&pkt->list, &devp->pkt_list);
		spin_unlock_irqrestore(&devp->pkt_list_lock, flags);
		return -EFAULT;
	}

	ret = pkt->size;
	glink_rx_done(devp->handle, pkt->data, false);
@@ -739,8 +746,13 @@ ssize_t glink_pkt_write(struct file *file,
	}

	ret = copy_from_user(data, buf, count);
	if (WARN_ON(ret != 0))
		return ret;
	if (ret) {
		GLINK_PKT_ERR(
		"%s copy_from_user failed ret[%d] on dev id:%d size %zu\n",
		 __func__, ret, devp->i, count);
		kfree(data);
		return -EFAULT;
	}

	ret = glink_tx(devp->handle, data, data, count, GLINK_TX_REQ_INTENT);
	if (ret) {