[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190205082727.GB118684@dtor-ws>
Date: Tue, 5 Feb 2019 00:27:27 -0800
From: Dmitry Torokhov <dmitry.torokhov@...il.com>
To: Sven Van Asbroeck <thesven73@...il.com>
Cc: Tejun Heo <tj@...nel.org>, Lai Jiangshan <jiangshanlai@...il.com>,
linux-kernel@...r.kernel.org, Sebastian Reichel <sre@...nel.org>,
Kees Cook <keescook@...omium.org>
Subject: Re: [RFC v1 2/3] max17042_battery: fix potential user-after-free on
module unload
On Mon, Feb 04, 2019 at 05:09:51PM -0500, Sven Van Asbroeck wrote:
> The work which is scheduled on a POR boot is potentially left
> pending or running until after the driver module is unloaded.
>
> Fix by using resource-controlled version of INIT_WORK().
>
> Signed-off-by: Sven Van Asbroeck <TheSven73@...glemail.com>
> ---
> drivers/power/supply/max17042_battery.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/power/supply/max17042_battery.c b/drivers/power/supply/max17042_battery.c
> index 2a8d75e5e930..a61e2b81f68a 100644
> --- a/drivers/power/supply/max17042_battery.c
> +++ b/drivers/power/supply/max17042_battery.c
> @@ -1100,7 +1100,10 @@ static int max17042_probe(struct i2c_client *client,
>
> regmap_read(chip->regmap, MAX17042_STATUS, &val);
> if (val & STATUS_POR_BIT) {
> - INIT_WORK(&chip->work, max17042_init_worker);
> + ret = devm_init_work(&client->dev, &chip->work,
> + max17042_init_worker);
> + if (ret)
> + return ret;
> schedule_work(&chip->work);
Are there many more instances of this? I am unsure if we need
devm_init_work() when we can easily do the same in remove() call.
Thanks.
--
Dmitry
Powered by blists - more mailing lists