Brad Bishop | bec4ebc | 2022-08-03 09:55:16 -0400 | [diff] [blame] | 1 | From 81d76e92b03a6f33acefd8aef168948c5f595205 Mon Sep 17 00:00:00 2001 |
| 2 | From: Viresh Kumar <viresh.kumar@linaro.org> |
| 3 | Date: Mon, 22 Feb 2021 12:48:06 +0530 |
| 4 | Subject: [PATCH 07/22] mailbox: arm_mhuv2: Skip calling kfree() with invalid |
| 5 | pointer |
| 6 | |
| 7 | It is possible that 'data' passed to kfree() is set to a error value |
| 8 | instead of allocated space. Make sure it doesn't get called with invalid |
| 9 | pointer. |
| 10 | |
| 11 | Fixes: 5a6338cce9f4 ("mailbox: arm_mhuv2: Add driver") |
| 12 | Cc: v5.11 <stable@vger.kernel.org> # v5.11 |
| 13 | Reported-by: kernel test robot <lkp@intel.com> |
| 14 | Reported-by: Dan Carpenter <dan.carpenter@oracle.com> |
| 15 | Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> |
| 16 | Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org> |
| 17 | |
| 18 | Upstream-Status: Backport [https://lkml.org/lkml/2021/2/22/57] |
| 19 | Signed-off-by: Arunachalam Ganapathy <arunachalam.ganapathy@arm.com> |
| 20 | --- |
| 21 | drivers/mailbox/arm_mhuv2.c | 4 +++- |
| 22 | 1 file changed, 3 insertions(+), 1 deletion(-) |
| 23 | |
| 24 | diff --git a/drivers/mailbox/arm_mhuv2.c b/drivers/mailbox/arm_mhuv2.c |
| 25 | index cdfb1939fabf..d997f8ebfa98 100644 |
| 26 | --- a/drivers/mailbox/arm_mhuv2.c |
| 27 | +++ b/drivers/mailbox/arm_mhuv2.c |
| 28 | @@ -699,7 +699,9 @@ static irqreturn_t mhuv2_receiver_interrupt(int irq, void *arg) |
| 29 | ret = IRQ_HANDLED; |
| 30 | } |
| 31 | |
| 32 | - kfree(data); |
| 33 | + if (!IS_ERR(data)) |
| 34 | + kfree(data); |
| 35 | + |
| 36 | return ret; |
| 37 | } |
| 38 | |
| 39 | -- |
| 40 | 2.17.1 |
| 41 | |