unmap memory mapped with devm_ioremap_resource

Constantine Shulyupin constantine.shulyupin at gmail.com
Sat Dec 10 01:53:14 EST 2022


It looks like the proper solution is to use two functions:
devm_iounmap and devm_release_mem_region. There are a lot of examples
in the kernel.

Regards,
Costa

On Sat, 10 Dec 2022 at 00:52, Adrian Fiergolski
<adrian.fiergolski at fastree3d.com> wrote:
>
> Hi,
>
> I checked the kernel source code and, as I wrote, in my opinion, the
> proposed devm_iounmap doesn't seem to release all resources allocated
> with devm_ioremap_resource. Thus, I don't see a point in testing it, and
> I am still looking for the proper solution.
>
> Jim, the original question is more than a week old.
>
> Regards,
> Adrian
>
> On 9.12.2022 at 21:35, Valdis Klētnieks wrote:
> > On Fri, 09 Dec 2022 12:58:20 -0700, jim.cromie at gmail.com said:
> >> On Fri, Dec 9, 2022 at 9:14 AM Adrian Fiergolski <adrian.fiergolski at fastree3d.com> wrote:
> >>> Does the community have any other ideas? Or I am wrong, and devm_iounmap is enough?
> >> I dunno, but it says you asked ~4 hrs ago.
> >> I bet you could just try it and get an answer faster.
> >> Do feel free to report back.
> > Note that it *is* possible for something to *look* like it works, but it leaves
> > dangling pointers or other hidden corruption that takes a while to surface.  I
> > once had to troubleshoot a userspace bug that worked fine on one system but
> > blew up on another with a different malloc() - some 6 million malloc calls
> > after the bug hit.
> >
> > Fortunately, the vast majority of kernel functions will return an error code if
> > anything at all fishy happened, so just checking return codes on *everything* is
> > usually good enough...
> >



-- 
Constantine Shulyupin



More information about the Kernelnewbies mailing list