[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHp75VemJWQDKFFrrCKWnUGHFiPhuh=4Aqhn8T6qF5yuMOCOKg@mail.gmail.com>
Date: Fri, 29 Jan 2021 19:26:21 +0200
From: Andy Shevchenko <andy.shevchenko@...il.com>
To: quanyang.wang@...driver.com
Cc: Linus Walleij <linus.walleij@...aro.org>,
Bartosz Golaszewski <bgolaszewski@...libre.com>,
"open list:GPIO SUBSYSTEM" <linux-gpio@...r.kernel.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] gpiolib: free device name on error path to fix kmemleak
On Fri, Jan 29, 2021 at 2:01 PM <quanyang.wang@...driver.com> wrote:
>
> From: Quanyang Wang <quanyang.wang@...driver.com>
>
> In gpiochip_add_data_with_key, we should check the return value of
> dev_set_name to ensure that device name is allocated successfully
> and then add a label on the error path to free device name to fix
> kmemleak as below:
Thanks for the report.
Unfortunately...
> + ret = dev_set_name(&gdev->dev, GPIOCHIP_NAME "%d", gdev->id);
> + if (ret)
> + goto err_free_ida;
...
> +err_free_dev_name:
> + kfree(dev_name(&gdev->dev));
...this approach seems to create a possible double free if I'm not mistaken.
The idea is that device name should be cleaned in kobject ->release()
callback when device is put.
Can you elaborate?
--
With Best Regards,
Andy Shevchenko
Powered by blists - more mailing lists