Re: [PATCH v2 5/7] regulator: plug of_node leak in regulator_register()'s error path

From: Michał Mirosław
Date: Wed Aug 12 2020 - 10:10:00 EST


On Wed, Aug 12, 2020 at 09:29:12AM +0300, Vladimir Zapolskiy wrote:
> On 8/12/20 4:31 AM, Michał Mirosław wrote:
[...]
> > config = kmemdup(cfg, sizeof(*cfg), GFP_KERNEL);
> > if (config == NULL) {
> > - kfree(rdev);
> > ret = -ENOMEM;
> > - goto rinse;
> > + goto clean;
[...]
> > clean:
> > if (dangling_of_gpiod)
> > gpiod_put(config->ena_gpiod);
>
> And above 'config' NULL pointer could be dereferenced now, right?

If config is NULL, dangling_of_gpiod cannot be true.

Best Regards,
Michał Mirosław