summaryrefslogtreecommitdiffstats
path: root/drivers/misc/ti-st
diff options
context:
space:
mode:
authorGigi Joseph <gigi.joseph@gmail.com>2015-01-09 04:49:03 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2015-01-12 14:04:11 +0100
commit0ec0cf19201da36af858a6bc052a13e88866f341 (patch)
tree7e2affa30dc0c565d01aed5fd1ff47a4a92b81a7 /drivers/misc/ti-st
parentdrivers: misc: ti-st: fix null pointer exception in st_kim_ref() (diff)
downloadlinux-0ec0cf19201da36af858a6bc052a13e88866f341.tar.xz
linux-0ec0cf19201da36af858a6bc052a13e88866f341.zip
drivers:misc:ti-st: protect against bad packets
We encounter situations where we got bad packet type from the UART (probably due to platform problem or UART driver issues) which caused us out of boundary array access, which eventually led to kernel panic. Signed-off-by: Amir Ayun <amira@ti.com> Signed-off-by: Pavan Savoy <pavan_savoy@ti.com> Signed-off-by: Leonid Iziumtsev <x0153368@ti.com> Signed-off-by: Gigi Joseph <gigi.joseph@ti.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/misc/ti-st')
-rw-r--r--drivers/misc/ti-st/st_core.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/drivers/misc/ti-st/st_core.c b/drivers/misc/ti-st/st_core.c
index 54be83d3efdd..c8c6a363069c 100644
--- a/drivers/misc/ti-st/st_core.c
+++ b/drivers/misc/ti-st/st_core.c
@@ -343,12 +343,26 @@ void st_int_recv(void *disc_data,
/* Unknow packet? */
default:
type = *ptr;
- if (st_gdata->list[type] == NULL) {
- pr_err("chip/interface misbehavior dropping"
- " frame starting with 0x%02x", type);
- goto done;
+ /* Default case means non-HCILL packets,
+ * possibilities are packets for:
+ * (a) valid protocol - Supported Protocols within
+ * the ST_MAX_CHANNELS.
+ * (b) registered protocol - Checked by
+ * "st_gdata->list[type] == NULL)" are supported
+ * protocols only.
+ * Rules out any invalid protocol and
+ * unregistered protocols with channel ID < 16.
+ */
+
+ if ((type >= ST_MAX_CHANNELS) ||
+ (st_gdata->list[type] == NULL)) {
+ pr_err("chip/interface misbehavior: "
+ "dropping frame starting "
+ "with 0x%02x\n", type);
+ goto done;
}
+
st_gdata->rx_skb = alloc_skb(
st_gdata->list[type]->max_frame_size,
GFP_ATOMIC);
@@ -893,5 +907,3 @@ void st_core_exit(struct st_data_s *st_gdata)
kfree(st_gdata);
}
}
-
-