aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/misc/ti-st
diff options
context:
space:
mode:
authorGigi Joseph <gigi.joseph@gmail.com>2015-01-08 22:49:03 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2015-01-12 08:04:11 -0500
commit0ec0cf19201da36af858a6bc052a13e88866f341 (patch)
tree7e2affa30dc0c565d01aed5fd1ff47a4a92b81a7 /drivers/misc/ti-st
parent868eba8e13d592f2eb9774777c9f3d9286482154 (diff)
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,
343 /* Unknow packet? */ 343 /* Unknow packet? */
344 default: 344 default:
345 type = *ptr; 345 type = *ptr;
346 if (st_gdata->list[type] == NULL) {
347 pr_err("chip/interface misbehavior dropping"
348 " frame starting with 0x%02x", type);
349 goto done;
350 346
347 /* Default case means non-HCILL packets,
348 * possibilities are packets for:
349 * (a) valid protocol - Supported Protocols within
350 * the ST_MAX_CHANNELS.
351 * (b) registered protocol - Checked by
352 * "st_gdata->list[type] == NULL)" are supported
353 * protocols only.
354 * Rules out any invalid protocol and
355 * unregistered protocols with channel ID < 16.
356 */
357
358 if ((type >= ST_MAX_CHANNELS) ||
359 (st_gdata->list[type] == NULL)) {
360 pr_err("chip/interface misbehavior: "
361 "dropping frame starting "
362 "with 0x%02x\n", type);
363 goto done;
351 } 364 }
365
352 st_gdata->rx_skb = alloc_skb( 366 st_gdata->rx_skb = alloc_skb(
353 st_gdata->list[type]->max_frame_size, 367 st_gdata->list[type]->max_frame_size,
354 GFP_ATOMIC); 368 GFP_ATOMIC);
@@ -893,5 +907,3 @@ void st_core_exit(struct st_data_s *st_gdata)
893 kfree(st_gdata); 907 kfree(st_gdata);
894 } 908 }
895} 909}
896
897