提交 0ec0cf19 编写于 作者: G Gigi Joseph 提交者: Greg Kroah-Hartman

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: NAmir Ayun <amira@ti.com>
Signed-off-by: NPavan Savoy <pavan_savoy@ti.com>
Signed-off-by: NLeonid Iziumtsev <x0153368@ti.com>
Signed-off-by: NGigi Joseph <gigi.joseph@ti.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 868eba8e
......@@ -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);
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册