Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1471287 > unrolled thread
| Started by | Baoyou Xie <baoyou.xie@linaro.org> |
|---|---|
| First post | 2016-08-28 09:00 +0200 |
| Last post | 2016-08-28 09:00 +0200 |
| Articles | 1 — 1 participant |
Back to article view | Back to linux.kernel
[PATCH] memstick: r592: add sanity check in r592.c Baoyou Xie <baoyou.xie@linaro.org> - 2016-08-28 09:00 +0200
| From | Baoyou Xie <baoyou.xie@linaro.org> |
|---|---|
| Date | 2016-08-28 09:00 +0200 |
| Subject | [PATCH] memstick: r592: add sanity check in r592.c |
| Message-ID | <sb2eu-6Ji-15@gated-at.bofh.it> |
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@linaro.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
Back to top | Article view | linux.kernel
csiph-web