Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mfd: wm831x-auxadc: Prevent use after free in wm831x_auxadc_read_irq()

The "req" struct is always added to the "wm831x->auxadc_pending" list,
but it's only removed from the list on the success path. If a failure
occurs then the "req" struct is freed but it's still on the list,
leading to a use after free.

Fixes: 78bb3688ea18 ("mfd: Support multiple active WM831x AUXADC conversions")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>

authored by

Dan Carpenter and committed by
Lee Jones
26783d74 6a8fac01

+1 -2
+1 -2
drivers/mfd/wm831x-auxadc.c
··· 93 93 wait_for_completion_timeout(&req->done, msecs_to_jiffies(500)); 94 94 95 95 mutex_lock(&wm831x->auxadc_lock); 96 - 97 - list_del(&req->list); 98 96 ret = req->val; 99 97 100 98 out: 99 + list_del(&req->list); 101 100 mutex_unlock(&wm831x->auxadc_lock); 102 101 103 102 kfree(req);