2015-07-29 20:26:35

by Vladimir Zapolskiy

[permalink] [raw]
Subject: [PATCH] firmware: fix wrong memory deallocation in fw_add_devm_name()

Device resource data allocated with devres_alloc() must be deallocated
by devres_free().

Signed-off-by: Vladimir Zapolskiy <[email protected]>
---
drivers/base/firmware_class.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
index 894bda1..8524450 100644
--- a/drivers/base/firmware_class.c
+++ b/drivers/base/firmware_class.c
@@ -443,7 +443,7 @@ static int fw_add_devm_name(struct device *dev, const char *name)
return -ENOMEM;
fwn->name = kstrdup_const(name, GFP_KERNEL);
if (!fwn->name) {
- kfree(fwn);
+ devres_free(fwn);
return -ENOMEM;
}

--
2.1.4


2015-07-30 07:48:54

by Ming Lei

[permalink] [raw]
Subject: Re: [PATCH] firmware: fix wrong memory deallocation in fw_add_devm_name()

On Wed, Jul 29, 2015 at 4:26 PM, Vladimir Zapolskiy <[email protected]> wrote:
> Device resource data allocated with devres_alloc() must be deallocated
> by devres_free().
>
> Signed-off-by: Vladimir Zapolskiy <[email protected]>

Acked-by: Ming Lei <[email protected]>

> ---
> drivers/base/firmware_class.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
> index 894bda1..8524450 100644
> --- a/drivers/base/firmware_class.c
> +++ b/drivers/base/firmware_class.c
> @@ -443,7 +443,7 @@ static int fw_add_devm_name(struct device *dev, const char *name)
> return -ENOMEM;
> fwn->name = kstrdup_const(name, GFP_KERNEL);
> if (!fwn->name) {
> - kfree(fwn);
> + devres_free(fwn);
> return -ENOMEM;
> }
>
> --
> 2.1.4
>