Commit 78bb9697e2c4b62c426f1a2571c293a2e4463adf
Committed by
Greg Kroah-Hartman
1 parent
74a4fcf19e
Exists in
master
and in
4 other branches
drivers:misc: ti-st: fail-safe on wrong pkt type
Texas Instrument's shared transport driver interpret incoming data from the UART based on the various protocol drivers registered to the driver such as btwilink driver or FM or GPS driver which provide logical channel IDs. In case of bad-behavior from chip such as HCI Event response for a GPS command or a HCI Event (h/w error event) for a FM response & In case of bad-behavior from UART driver such as dropping data bytes a fail-safe is required to avoid kernel panic. Signed-off-by: Pavan Savoy <pavan_savoy@ti.com> Signed-off-by: Vijay Badawadagi <bvijay@ti.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Showing 1 changed file with 7 additions and 0 deletions Side-by-side Diff
drivers/misc/ti-st/st_core.c
... | ... | @@ -338,6 +338,12 @@ |
338 | 338 | /* Unknow packet? */ |
339 | 339 | default: |
340 | 340 | type = *ptr; |
341 | + if (st_gdata->list[type] == NULL) { | |
342 | + pr_err("chip/interface misbehavior dropping" | |
343 | + " frame starting with 0x%02x", type); | |
344 | + goto done; | |
345 | + | |
346 | + } | |
341 | 347 | st_gdata->rx_skb = alloc_skb( |
342 | 348 | st_gdata->list[type]->max_frame_size, |
343 | 349 | GFP_ATOMIC); |
... | ... | @@ -354,6 +360,7 @@ |
354 | 360 | ptr++; |
355 | 361 | count--; |
356 | 362 | } |
363 | +done: | |
357 | 364 | spin_unlock_irqrestore(&st_gdata->lock, flags); |
358 | 365 | pr_debug("done %s", __func__); |
359 | 366 | return; |