Skip to contentSkip to conversation

isdn/gigaset: add a kfree() to error path

PATCH In review Dan Carpenter 2 participants 3 messages Jun 28, 2010 – Jun 29, 2010

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 isdn/gigaset: add a kfree() to error path

We should free "commands" here. The main reason is to please the static checkers.

drivers/isdn/gigaset/i4l.c +1 -0
index f01c3c2..f1abb8f 100644
@@ -419,6 +419,7 @@ oom:
 	dev_err(bcs->cs->dev, "out of memory\n");
 	for (i = 0; i < AT_NUM; ++i)
 		kfree(commands[i]);
+	kfree(commands);
 	return -ENOMEM;
 }
 
#1 lore raw

Dan,

thanks for your patch. It is quite correct as it stands. There is however another problem with that error path, in that it also doesn't free the previously allocated channel. I prefer not to carry two separate patches for that, so I'm replacing your patch with the following augmented patch, which I'll submit together with my other pending patches for 2.6.36 soon:

Subject: [PATCH] isdn/gigaset: fix leaks in error path

Take care to free all previously allocated ressources in the "out of memory" error path of the ISDN_CMD_DIAL branch. Based on an original patch by Dan Carpenter.

Impact: bugfix

---
 drivers/isdn/gigaset/i4l.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
drivers/isdn/gigaset/i4l.c +2 -0
index 1d084bb..34bca37 100644
@@ -419,6 +419,8 @@ oom:
 	dev_err(bcs->cs->dev, "out of memory\n");
 	for (i = 0; i < AT_NUM; ++i)
 		kfree(commands[i]);
+	kfree(commands);
+	gigaset_free_channel(bcs);
 	return -ENOMEM;
 }
 
Signature · 7 lines
1.6.5.3.298.g39add

-- 
Tilman Schmidt                    E-Mail: [email protected]
Bonn, Germany
Diese Nachricht besteht zu 100% aus wiederverwerteten Bits.
Ungeöffnet mindestens haltbar bis: (siehe Rückseite)
author Acked-by
#2 lore raw
Quoted 10 lines · Tilman Schmidt

Dan,

thanks for your patch. It is quite correct as it stands. There is however another problem with that error path, in that it also doesn't free the previously allocated channel. I prefer not to carry two separate patches for that, so I'm replacing your patch with the following augmented patch, which I'll submit together with my other pending patches for 2.6.36 soon:

Good deal.

regards,
dan carpenter