* [patch 2/2 -next] hid-lg4ff: add a kfree() to an error path
@ 2011-08-18 13:43 ` Dan Carpenter
0 siblings, 0 replies; 8+ messages in thread
From: Dan Carpenter @ 2011-08-18 13:43 UTC (permalink / raw)
To: Jiri Kosina; +Cc: open list:HID CORE LAYER, kernel-janitors
There is a small rare potential memory leak here. But it's easy to
fix.
Signed-off-by: Dan Carpenter <error27@gmail.com>
diff --git a/drivers/hid/hid-lg4ff.c b/drivers/hid/hid-lg4ff.c
index dc38c2d..2b4bbcb 100644
--- a/drivers/hid/hid-lg4ff.c
+++ b/drivers/hid/hid-lg4ff.c
@@ -438,6 +438,7 @@ int lg4ff_init(struct hid_device *hid)
entry->device_id = (char *)kzalloc(strlen((&hid->dev)->kobj.name) + 1, GFP_KERNEL);
if (!entry->device_id) {
hid_err(hid, "Cannot set device_id, insufficient memory.\n");
+ kfree(entry);
return -ENOMEM;
}
strcpy(entry->device_id, (&hid->dev)->kobj.name);
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [patch 2/2 -next] hid-lg4ff: add a kfree() to an error path
@ 2011-08-18 13:43 ` Dan Carpenter
0 siblings, 0 replies; 8+ messages in thread
From: Dan Carpenter @ 2011-08-18 13:43 UTC (permalink / raw)
To: Jiri Kosina; +Cc: open list:HID CORE LAYER, kernel-janitors
There is a small rare potential memory leak here. But it's easy to
fix.
Signed-off-by: Dan Carpenter <error27@gmail.com>
diff --git a/drivers/hid/hid-lg4ff.c b/drivers/hid/hid-lg4ff.c
index dc38c2d..2b4bbcb 100644
--- a/drivers/hid/hid-lg4ff.c
+++ b/drivers/hid/hid-lg4ff.c
@@ -438,6 +438,7 @@ int lg4ff_init(struct hid_device *hid)
entry->device_id = (char *)kzalloc(strlen((&hid->dev)->kobj.name) + 1, GFP_KERNEL);
if (!entry->device_id) {
hid_err(hid, "Cannot set device_id, insufficient memory.\n");
+ kfree(entry);
return -ENOMEM;
}
strcpy(entry->device_id, (&hid->dev)->kobj.name);
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [patch 2/2 -next] hid-lg4ff: add a kfree() to an error path
[not found] ` <CAMvewQJigdY81gPrpndqV=FxN+cEeif4NkzSbBZKCO4z3guQew@mail.gmail.com>
@ 2011-08-18 16:24 ` Dan Carpenter
0 siblings, 0 replies; 8+ messages in thread
From: Dan Carpenter @ 2011-08-18 16:24 UTC (permalink / raw)
To: Zic Rim; +Cc: Jiri Kosina, open list:HID CORE LAYER, kernel-janitors
On Thu, Aug 18, 2011 at 07:59:32PM +0530, Zic Rim wrote:
> There is no leak here. If kzalloc fails , it means memory is not allocated.
> It is wrong to free something that is not allocated .
No. The entry allocation succeeded and the entry->device_id
allocation failed. Look again.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [patch 2/2 -next] hid-lg4ff: add a kfree() to an error path
@ 2011-08-18 16:24 ` Dan Carpenter
0 siblings, 0 replies; 8+ messages in thread
From: Dan Carpenter @ 2011-08-18 16:24 UTC (permalink / raw)
To: Zic Rim; +Cc: Jiri Kosina, open list:HID CORE LAYER, kernel-janitors
On Thu, Aug 18, 2011 at 07:59:32PM +0530, Zic Rim wrote:
> There is no leak here. If kzalloc fails , it means memory is not allocated.
> It is wrong to free something that is not allocated .
No. The entry allocation succeeded and the entry->device_id
allocation failed. Look again.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 8+ messages in thread
* [patch 2/2 -next v2] hid-lg4ff: add a kfree() to an error path
[not found] ` <4E4D2E4A.3020205@bfs.de>
@ 2011-08-19 8:00 ` Dan Carpenter
0 siblings, 0 replies; 8+ messages in thread
From: Dan Carpenter @ 2011-08-19 8:00 UTC (permalink / raw)
To: walter harms; +Cc: Jiri Kosina, open, list, HID CORE LAYER, kernel-janitors
There is a small rare potential memory leak here. Also Walter Harms
points out that we can do a small cleanup as well by using kstrdup().
Signed-off-by: Dan Carpenter <error27@gmail.com>
diff --git a/drivers/hid/hid-lg4ff.c b/drivers/hid/hid-lg4ff.c
index dc38c2d..cbb0089 100644
--- a/drivers/hid/hid-lg4ff.c
+++ b/drivers/hid/hid-lg4ff.c
@@ -435,12 +435,12 @@ int lg4ff_init(struct hid_device *hid)
hid_err(hid, "Cannot add device, insufficient memory.\n");
return -ENOMEM;
}
- entry->device_id = (char *)kzalloc(strlen((&hid->dev)->kobj.name) + 1, GFP_KERNEL);
+ entry->device_id = kstrdup((&hid->dev)->kobj.name, GFP_KERNEL);
if (!entry->device_id) {
hid_err(hid, "Cannot set device_id, insufficient memory.\n");
+ kfree(entry);
return -ENOMEM;
}
- strcpy(entry->device_id, (&hid->dev)->kobj.name);
entry->min_range = lg4ff_devices[i].min_range;
entry->max_range = lg4ff_devices[i].max_range;
entry->set_range = lg4ff_devices[i].set_range;
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [patch 2/2 -next v2] hid-lg4ff: add a kfree() to an error path
@ 2011-08-19 8:00 ` Dan Carpenter
0 siblings, 0 replies; 8+ messages in thread
From: Dan Carpenter @ 2011-08-19 8:00 UTC (permalink / raw)
To: walter harms; +Cc: Jiri Kosina, open, list, HID CORE LAYER, kernel-janitors
There is a small rare potential memory leak here. Also Walter Harms
points out that we can do a small cleanup as well by using kstrdup().
Signed-off-by: Dan Carpenter <error27@gmail.com>
diff --git a/drivers/hid/hid-lg4ff.c b/drivers/hid/hid-lg4ff.c
index dc38c2d..cbb0089 100644
--- a/drivers/hid/hid-lg4ff.c
+++ b/drivers/hid/hid-lg4ff.c
@@ -435,12 +435,12 @@ int lg4ff_init(struct hid_device *hid)
hid_err(hid, "Cannot add device, insufficient memory.\n");
return -ENOMEM;
}
- entry->device_id = (char *)kzalloc(strlen((&hid->dev)->kobj.name) + 1, GFP_KERNEL);
+ entry->device_id = kstrdup((&hid->dev)->kobj.name, GFP_KERNEL);
if (!entry->device_id) {
hid_err(hid, "Cannot set device_id, insufficient memory.\n");
+ kfree(entry);
return -ENOMEM;
}
- strcpy(entry->device_id, (&hid->dev)->kobj.name);
entry->min_range = lg4ff_devices[i].min_range;
entry->max_range = lg4ff_devices[i].max_range;
entry->set_range = lg4ff_devices[i].set_range;
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [patch 2/2 -next v2] hid-lg4ff: add a kfree() to an error path
2011-08-19 8:00 ` Dan Carpenter
@ 2011-08-23 8:46 ` Jiri Kosina
-1 siblings, 0 replies; 8+ messages in thread
From: Jiri Kosina @ 2011-08-23 8:46 UTC (permalink / raw)
To: Dan Carpenter; +Cc: walter harms, open, list, HID CORE LAYER, kernel-janitors
On Fri, 19 Aug 2011, Dan Carpenter wrote:
> There is a small rare potential memory leak here. Also Walter Harms
> points out that we can do a small cleanup as well by using kstrdup().
>
> Signed-off-by: Dan Carpenter <error27@gmail.com>
>
> diff --git a/drivers/hid/hid-lg4ff.c b/drivers/hid/hid-lg4ff.c
> index dc38c2d..cbb0089 100644
> --- a/drivers/hid/hid-lg4ff.c
> +++ b/drivers/hid/hid-lg4ff.c
> @@ -435,12 +435,12 @@ int lg4ff_init(struct hid_device *hid)
> hid_err(hid, "Cannot add device, insufficient memory.\n");
> return -ENOMEM;
> }
> - entry->device_id = (char *)kzalloc(strlen((&hid->dev)->kobj.name) + 1, GFP_KERNEL);
> + entry->device_id = kstrdup((&hid->dev)->kobj.name, GFP_KERNEL);
> if (!entry->device_id) {
> hid_err(hid, "Cannot set device_id, insufficient memory.\n");
> + kfree(entry);
> return -ENOMEM;
> }
> - strcpy(entry->device_id, (&hid->dev)->kobj.name);
> entry->min_range = lg4ff_devices[i].min_range;
> entry->max_range = lg4ff_devices[i].max_range;
> entry->set_range = lg4ff_devices[i].set_range;
>
Applied, thanks.
--
Jiri Kosina
SUSE Labs
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [patch 2/2 -next v2] hid-lg4ff: add a kfree() to an error path
@ 2011-08-23 8:46 ` Jiri Kosina
0 siblings, 0 replies; 8+ messages in thread
From: Jiri Kosina @ 2011-08-23 8:46 UTC (permalink / raw)
To: Dan Carpenter; +Cc: walter harms, open, list, HID CORE LAYER, kernel-janitors
On Fri, 19 Aug 2011, Dan Carpenter wrote:
> There is a small rare potential memory leak here. Also Walter Harms
> points out that we can do a small cleanup as well by using kstrdup().
>
> Signed-off-by: Dan Carpenter <error27@gmail.com>
>
> diff --git a/drivers/hid/hid-lg4ff.c b/drivers/hid/hid-lg4ff.c
> index dc38c2d..cbb0089 100644
> --- a/drivers/hid/hid-lg4ff.c
> +++ b/drivers/hid/hid-lg4ff.c
> @@ -435,12 +435,12 @@ int lg4ff_init(struct hid_device *hid)
> hid_err(hid, "Cannot add device, insufficient memory.\n");
> return -ENOMEM;
> }
> - entry->device_id = (char *)kzalloc(strlen((&hid->dev)->kobj.name) + 1, GFP_KERNEL);
> + entry->device_id = kstrdup((&hid->dev)->kobj.name, GFP_KERNEL);
> if (!entry->device_id) {
> hid_err(hid, "Cannot set device_id, insufficient memory.\n");
> + kfree(entry);
> return -ENOMEM;
> }
> - strcpy(entry->device_id, (&hid->dev)->kobj.name);
> entry->min_range = lg4ff_devices[i].min_range;
> entry->max_range = lg4ff_devices[i].max_range;
> entry->set_range = lg4ff_devices[i].set_range;
>
Applied, thanks.
--
Jiri Kosina
SUSE Labs
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2011-08-23 8:46 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-18 13:43 [patch 2/2 -next] hid-lg4ff: add a kfree() to an error path Dan Carpenter
2011-08-18 13:43 ` Dan Carpenter
[not found] ` <CAMvewQJigdY81gPrpndqV=FxN+cEeif4NkzSbBZKCO4z3guQew@mail.gmail.com>
2011-08-18 16:24 ` Dan Carpenter
2011-08-18 16:24 ` Dan Carpenter
[not found] ` <4E4D2E4A.3020205@bfs.de>
2011-08-19 8:00 ` [patch 2/2 -next v2] " Dan Carpenter
2011-08-19 8:00 ` Dan Carpenter
2011-08-23 8:46 ` Jiri Kosina
2011-08-23 8:46 ` Jiri Kosina
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.