Re: devm_* vs. PROBE_DEFFER: memory leaks?

From: Sebastian Reichel
Date: Fri May 31 2019 - 09:30:45 EST


Hi,

On Fri, May 31, 2019 at 10:52:10AM +0200, Pavel Machek wrote:
> Is devm_ supposed to work with EPROBE_DEFFER?

Sure.

> Probe function is now called multiple times;
> is memory freed between calling probe()?

Yes, EPROBE_DEFER is an error code, so devm resources
are released.

> Will allocations from failed probe()s remain after the driver is
> inserted successfully, leaking memory?

devm_ is connected to the device, not to the driver.

Since code is better than words, check drivers/base/dd.c yourself.
The relevant function name is really_probe(), interesting part for
you starts at ret = drv->probe(dev) line.

-- Sebastian

Attachment: signature.asc
Description: PGP signature