[<prev] [next>] [day] [month] [year] [list]
Message-Id: <1472367286-14528-1-git-send-email-baoyou.xie@linaro.org>
Date: Sun, 28 Aug 2016 14:54:46 +0800
From: Baoyou Xie <baoyou.xie@...aro.org>
To: maximlevitsky@...il.com
Cc: linux-kernel@...r.kernel.org, arnd@...aro.org,
baoyou.xie@...aro.org, xie.baoyou@....com.cn
Subject: [PATCH] memstick: r592: add sanity check in r592.c
in function memstick_debug_get_tpc_name, it miss sanity check and
will cause a panic.
so this patch checks if the tpc parameter is valid, and if not so,
it returns a dummy value to caller.
Signed-off-by: Baoyou Xie <baoyou.xie@...aro.org>
---
drivers/memstick/host/r592.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/memstick/host/r592.c b/drivers/memstick/host/r592.c
index d5cfb50..fc752ae 100644
--- a/drivers/memstick/host/r592.c
+++ b/drivers/memstick/host/r592.c
@@ -49,6 +49,9 @@ static const char *tpc_names[] = {
*/
const char *memstick_debug_get_tpc_name(int tpc)
{
+ if (tpc < 1 || tpc > ARRAY_SIZE(tpc_names))
+ return "";
+
return tpc_names[tpc-1];
}
EXPORT_SYMBOL(memstick_debug_get_tpc_name);
--
2.7.4
Powered by blists - more mailing lists