We need to check for MAX_TS_FILTER_CHAIN so that we don't overrun the array of ts_filter pointers when we have MAX_TS_FILTER_CHAIN filters.
- Check the boundary - Small cleanups Signed-off-by: Nelson Castillo <[email protected]> --- drivers/input/touchscreen/ts_filter.c | 8 +++++--- 1 files changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/input/touchscreen/ts_filter.c b/drivers/input/touchscreen/ts_filter.c index 4c650a5..e141bd8 100644 --- a/drivers/input/touchscreen/ts_filter.c +++ b/drivers/input/touchscreen/ts_filter.c @@ -29,13 +29,13 @@ int ts_filter_create_chain(struct ts_filter_api **api, void **config, if (!api) return 0; - while (*api && (count < MAX_TS_FILTER_CHAIN)) { + while (*api && count < MAX_TS_FILTER_CHAIN) { *list = ((*api)->create)(*config++, count_coords); if (!*list) { printk(KERN_ERR "Filter %d failed init\n", count); return count; } - (*list)->api = (struct ts_filter_api *)*api++; + (*list)->api = *api++; if (last) last->next = *list; last = *list; @@ -50,8 +50,10 @@ EXPORT_SYMBOL_GPL(ts_filter_create_chain); void ts_filter_destroy_chain(struct ts_filter **list) { struct ts_filter **first; + int count = 0; + first = list; - while (*list) { + while (*list && count++ < MAX_TS_FILTER_CHAIN) { ((*list)->api->destroy)(*list); list++; }
