diff options
author | David Woodhouse <David.Woodhouse@intel.com> | 2013-03-14 09:21:00 -0400 |
---|---|---|
committer | David Woodhouse <David.Woodhouse@intel.com> | 2013-03-18 07:40:12 -0400 |
commit | fe9ab00f8354a4c388e30301859c5741590c3809 (patch) | |
tree | 025f63833a6610ea7e2baaf9031bb53ae8e4ff3e | |
parent | a937536b868b8369b98967929045f1df54234323 (diff) |
dell-laptop: Fix krealloc() misuse in parse_da_table()
If krealloc() returns NULL, it *doesn't* free the original. So any code
of the form 'foo = krealloc(foo, …);' is almost certainly a bug.
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
-rw-r--r-- | drivers/platform/x86/dell-laptop.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/drivers/platform/x86/dell-laptop.c b/drivers/platform/x86/dell-laptop.c index fa3ee6209572..1134119521ac 100644 --- a/drivers/platform/x86/dell-laptop.c +++ b/drivers/platform/x86/dell-laptop.c | |||
@@ -284,6 +284,7 @@ static void __init parse_da_table(const struct dmi_header *dm) | |||
284 | { | 284 | { |
285 | /* Final token is a terminator, so we don't want to copy it */ | 285 | /* Final token is a terminator, so we don't want to copy it */ |
286 | int tokens = (dm->length-11)/sizeof(struct calling_interface_token)-1; | 286 | int tokens = (dm->length-11)/sizeof(struct calling_interface_token)-1; |
287 | struct calling_interface_token *new_da_tokens; | ||
287 | struct calling_interface_structure *table = | 288 | struct calling_interface_structure *table = |
288 | container_of(dm, struct calling_interface_structure, header); | 289 | container_of(dm, struct calling_interface_structure, header); |
289 | 290 | ||
@@ -296,12 +297,13 @@ static void __init parse_da_table(const struct dmi_header *dm) | |||
296 | da_command_address = table->cmdIOAddress; | 297 | da_command_address = table->cmdIOAddress; |
297 | da_command_code = table->cmdIOCode; | 298 | da_command_code = table->cmdIOCode; |
298 | 299 | ||
299 | da_tokens = krealloc(da_tokens, (da_num_tokens + tokens) * | 300 | new_da_tokens = krealloc(da_tokens, (da_num_tokens + tokens) * |
300 | sizeof(struct calling_interface_token), | 301 | sizeof(struct calling_interface_token), |
301 | GFP_KERNEL); | 302 | GFP_KERNEL); |
302 | 303 | ||
303 | if (!da_tokens) | 304 | if (!new_da_tokens) |
304 | return; | 305 | return; |
306 | da_tokens = new_da_tokens; | ||
305 | 307 | ||
306 | memcpy(da_tokens+da_num_tokens, table->tokens, | 308 | memcpy(da_tokens+da_num_tokens, table->tokens, |
307 | sizeof(struct calling_interface_token) * tokens); | 309 | sizeof(struct calling_interface_token) * tokens); |