fix adm9240 oops
Subsystems (2)
PATCH 1/1 fix adm9240 oops
The adm9240 driver, in adm9240_detect(), allocates a structure. The error path attempts to kfree() a subfield of that structure, resulting in an oops (or slab corruption) if the hardware is not present. This one seems worth fixing for 2.6.13.
jon
drivers/hwmon/adm9240.c renamed from drivers/hwmon/adm9240.c.orig +1 -1
@@ -616,7 +616,7 @@ static int adm9240_detect(struct i2c_adareturn 0 ; exit_free: -kfree (new_client); +kfree (data); exit:return err; }
PATCH 1/1 drivers/hwmon/*: kfree() correct pointers
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.
---
drivers/hwmon/adm1026.c | 2 +- drivers/hwmon/adm1031.c | 2 +- drivers/hwmon/adm9240.c | 2 +- drivers/hwmon/smsc47b397.c | 2 +- drivers/hwmon/smsc47m1.c | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-)
drivers/hwmon/adm1026.c +1 -1
@@ -1691,7 +1691,7 @@ int adm1026_detect(struct i2c_adapter *a/* Error out and cleanup code */ exitfree: -kfree (new_client); +kfree (data); exit:return err; }
drivers/hwmon/adm1031.c +1 -1
@@ -834,7 +834,7 @@ static int adm1031_detect(struct i2c_adareturn 0 ; exit_free: -kfree (new_client); +kfree (data); exit:return err; }
drivers/hwmon/adm9240.c +1 -1
@@ -616,7 +616,7 @@ static int adm9240_detect(struct i2c_adareturn 0 ; exit_free: -kfree (new_client); +kfree (data); exit:return err; }
drivers/hwmon/smsc47b397.c +1 -1
@@ -298,7 +298,7 @@ static int smsc47b397_detect(struct i2c_return 0 ; error_free: -kfree (new_client); +kfree (data); error_release:release_region (addr,SMSC_EXTENT );return err;
drivers/hwmon/smsc47m1.c +1 -1
@@ -495,7 +495,7 @@ static int smsc47m1_detect(struct i2c_adreturn 0 ; error_free: -kfree (new_client); +kfree (data); error_release:release_region (address,SMSC_EXTENT );return err;
Re: [PATCH] drivers/hwmon/*: kfree() correct pointers
Hi Alexey,
Quoted 7 lines
The adm9240 driver, in
adm9240_detect(), allocates a structure. The error path attempts tokfree()->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.
Already fixed in Greg's i2c tree and -mm for quite some time now...
Thanks,
Signature · 1 line
Jean Delvare
Re: [PATCH] drivers/hwmon/*: kfree() correct pointers
Quoted 1 line
Already fixed in Greg's i2c tree and -mm for quite some time now...
So it is. The comment says, however, that "the existing code works somewhat by accident." In the case of the 9240 driver, however, the existing code demonstrably does not work - it oopsed on me. The patch in Greg's tree looks fine (it's a straightforward fix, after all); I'd recommend that it be merged before 2.6.13.
jon
Jonathan Corbet
Executive editor, LWN.net
[email protected]
Re: [PATCH] drivers/hwmon/*: kfree() correct pointers
Hi Jonathan,
Quoted 5 lines
Quoted 1 line
Already fixed in Greg's i2c tree and -mm for quite some time now...
So it is. The comment says, however, that "the existing code works somewhat by accident." In the case of the 9240 driver, however, the existing code demonstrably does not work - it oopsed on me.
I too did notice that the adm9240 case was worse than the four other ones back then, but when I tried to get it to crash, it never did. This is the reason why I did not push this patch upstream faster. I wonder why it now does oops on you.
I also believe that this patch was somewhat misnamed. It is not related to the new hwmon class, but jut happened to change the same part of these five drivers. With a better name, the patch would most probably have been selected by Greg in the last batch of i2c patches to Linus.
Quoted 2 lines
The patch in Greg's tree looks fine (it's a straightforward fix, after all);
I wouldn't call it straightforward, but it certainly has been reviewed and tested well enough by now to be considered safe.
Quoted 1 line
I'd recommend that it be merged before 2.6.13.
Fine with me.
Thanks,
Signature · 1 line
Jean Delvare