Re: ib_uverbs_add_one() memory leak

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Bart,

On 9/16/2018 8:25 PM, Bart Van Assche wrote:
> Hello,
> 
> If I run blktests (which unloads and reloads the rdma_rxe kernel module repeatedly) against kernel v4.19-rc2 then kmemleak reports the following leak complaint many times:
> 
> unreferenced object 0xffff8800d4942c00 (size 96):
>   comm "modprobe", pid 1148, jiffies 4295023189 (age 550.240s)
>   hex dump (first 32 bytes):
>     00 00 00 00 ad 4e ad de ff ff ff ff 00 00 00 00  .....N..........
>     ff ff ff ff ff ff ff ff a0 04 f1 a0 ff ff ff ff  ................
>   backtrace:
>     [<0000000013946701>] ib_uverbs_add_one+0x231/0x470 [ib_uverbs]
>     [<00000000df577ad1>] ib_register_client+0x5b/0x100 [ib_core]
>     [<000000000fe5c216>] 0xffffffffa0e180e0
>     [<00000000f4d53513>] do_one_initcall+0x93/0x37c
>     [<00000000349122fa>] do_init_module+0xde/0x334
>     [<00000000525a45c2>] load_module+0x3b30/0x46c0
>     [<000000007aed46a5>] __do_sys_finit_module+0x176/0x1a0
>     [<00000000475b194a>] do_syscall_64+0x72/0x230
>     [<00000000e22ef972>] entry_SYSCALL_64_after_hwframe+0x49/0xbe
>     [<000000009ada268d>] 0xffffffffffffffff
> 
> (gdb) list *(ib_uverbs_add_one+0x231)
> 0x1381 is in ib_uverbs_add_one (drivers/infiniband/core/uverbs_main.c: 1003).
> 998                               struct ib_uverbs_device *uverbs_dev)
> 999     {
> 1000            struct uverbs_api *uapi;
> 1001
> 1002            uapi = uverbs_alloc_api(device->driver_specs,
>                     device->driver_id);
> 1003            if (IS_ERR(uapi))
> 1004                    return PTR_ERR(uapi);
> 1005
> 1006            uverbs_dev->uapi = uapi;
> 1007            return 0;
> 
> Had anyone else already observed this?
> 
> Thanks,
> 
> Bart.

Can you please try the patch below?
Also, you should probably use rc4 is it contains a fix from Parav:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/drivers/infiniband/core/uverbs_main.c?id=08e74be103051861eb2c1ee52a2dcf119cde264f

commit 00788797517e542db51a5d9c8defeacc357e9967 (HEAD -> master)
Author: Mark Bloch <markb@xxxxxxxxxxxx>
Date:   Mon Sep 17 18:12:40 2018 +0000

    IB/uverbs: Free uapi on destroy

    Make sure we free uapi once we clean the radix tree.

    Fixes: 9ed3e5f44772 ("IB/uverbs: Build the specs into a radix tree at runtime")
    Signed-off-by: Mark Bloch <markb@xxxxxxxxxxxx>

diff --git a/drivers/infiniband/core/uverbs_uapi.c b/drivers/infiniband/core/uverbs_uapi.c
index 73ea6f0db88f..be854628a7c6 100644
--- a/drivers/infiniband/core/uverbs_uapi.c
+++ b/drivers/infiniband/core/uverbs_uapi.c
@@ -248,6 +248,7 @@ void uverbs_destroy_api(struct uverbs_api *uapi)
                kfree(rcu_dereference_protected(*slot, true));
                radix_tree_iter_delete(&uapi->radix, &iter, slot);
        }
+       kfree(uapi);
 }

 struct uverbs_api *uverbs_alloc_api(



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux