Skip to contentSkip to conversation

devm_* vs. PROBE_DEFFER: memory leaks?

DISCUSSION Pavel Machek 2 participants 2 messages May 31, 2019

lore
Share & tools
lore
#0 lore raw

Hi!

Is devm_ supposed to work with EPROBE_DEFFER?

Probe function is now called multiple times; is memory freed between calling probe()? Will allocations from failed probe()s remain after the driver is inserted successfully, leaking memory?

Thanks,
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#1 lore raw

Hi,

Quoted 1 line · Pavel Machek

Is devm_ supposed to work with EPROBE_DEFFER?

Sure.

Quoted 2 lines

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.

Quoted 2 lines

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