Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1665313

Re: [PATCH 1/1] uio: Fix uio_device memory leak

From Mike Christie <mchristi@redhat.com>
Newsgroups linux.kernel
Subject Re: [PATCH 1/1] uio: Fix uio_device memory leak
Date 2017-06-14 02:20 +0200
Message-ID <tS4cp-6os-1@gated-at.bofh.it> (permalink)
References <tPPrd-2PB-57@gated-at.bofh.it> <tRUG6-w3-15@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On 06/13/2017 09:01 AM, Greg KH wrote:
> On Wed, Jun 07, 2017 at 03:06:44PM -0500, Mike Christie wrote:
>> It looks like there might be 2 issues with the uio_device allocation, or it
>> looks like we are leaking the device for possibly a specific type of device
>> case that I could not find but one of you may know about.
>>
>> Issues:
>> 1. We use devm_kzalloc to allocate the uio_device, but the release
>> function, devm_kmalloc_release, is just a noop, so the memory is never freed.
> 
> What do you mean by this?  If the release function is a noop, lots of
> memory in the kernel is leaking.  UIO shouldn't have to do anything
> special here, is the devm api somehow broken?

Sorry. I misdiagnosed the problem. It's a noop, but we did kfree on the
entire devres and its data later.

The problem I was hitting is that memory is not freed until the parent
is removed. __uio_register_device does:

        idev = devm_kzalloc(parent, sizeof(*idev), GFP_KERNEL);
        if (!idev) {
                return -ENOMEM;
        }

so the devres's memory is associated with the parent. Is that intentional?

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 1/1] uio: Fix uio_device memory leak Mike Christie <mchristi@redhat.com> - 2017-06-07 22:10 +0200
  Re: [PATCH 1/1] uio: Fix uio_device memory leak Greg KH <gregkh@linuxfoundation.org> - 2017-06-13 16:10 +0200
    Re: [PATCH 1/1] uio: Fix uio_device memory leak Mike Christie <mchristi@redhat.com> - 2017-06-14 02:20 +0200
      Re: [PATCH 1/1] uio: Fix uio_device memory leak Mike Christie <mchristi@redhat.com> - 2017-06-14 02:40 +0200
        Re: [PATCH 1/1] uio: Fix uio_device memory leak Greg KH <gregkh@linuxfoundation.org> - 2017-06-14 07:10 +0200

csiph-web