Skip to content

Commit

Permalink
[PATCH] drivers/hwmon/*: kfree() correct pointers
Browse files Browse the repository at this point in the history
The adm9240 driver, in adm9240_detect(), allocates a structure.  The
error path attempts to kfree() ->client field of it (second one),
resulting in an oops (or slab corruption) if the hardware is not present.

->client field in adm1026, adm1031, smsc47b397 and smsc47m1 is the first in
${HWMON}_data structure, but fix them too.

Signed-off-by: Jonathan Corbet <corbet@lwn.net
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
  • Loading branch information
Alexey Dobriyan authored and Linus Torvalds committed Aug 26, 2005
1 parent d634cc1 commit 1f57ff8
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion drivers/hwmon/adm1026.c
Original file line number Diff line number Diff line change
Expand Up @@ -1691,7 +1691,7 @@ int adm1026_detect(struct i2c_adapter *adapter, int address,

/* Error out and cleanup code */
exitfree:
kfree(new_client);
kfree(data);
exit:
return err;
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/hwmon/adm1031.c
Original file line number Diff line number Diff line change
Expand Up @@ -834,7 +834,7 @@ static int adm1031_detect(struct i2c_adapter *adapter, int address, int kind)
return 0;

exit_free:
kfree(new_client);
kfree(data);
exit:
return err;
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/hwmon/adm9240.c
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ static int adm9240_detect(struct i2c_adapter *adapter, int address, int kind)

return 0;
exit_free:
kfree(new_client);
kfree(data);
exit:
return err;
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/hwmon/smsc47b397.c
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ static int smsc47b397_detect(struct i2c_adapter *adapter, int addr, int kind)
return 0;

error_free:
kfree(new_client);
kfree(data);
error_release:
release_region(addr, SMSC_EXTENT);
return err;
Expand Down
2 changes: 1 addition & 1 deletion drivers/hwmon/smsc47m1.c
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ static int smsc47m1_detect(struct i2c_adapter *adapter, int address, int kind)
return 0;

error_free:
kfree(new_client);
kfree(data);
error_release:
release_region(address, SMSC_EXTENT);
return err;
Expand Down

0 comments on commit 1f57ff8

Please sign in to comment.