diff options
author | Zhenyu Wang <zhenyu.z.wang@intel.com> | 2008-02-19 21:13:45 +0800 |
---|---|---|
committer | root <root@debian-eeepc.sh.intel.com> | 2008-02-19 21:13:45 +0800 |
commit | 293120bfc40a5b828567551954d8312639e73578 (patch) | |
tree | 7f6a2e2c132a82d86abe4409ad772c8761cf5ef3 /src/i830_quirks.c | |
parent | cdc5cb7c3d24f36a30fb931b43ec6df8294709e2 (diff) |
Don't leak memory if no DMI info is provided by kernel
Diffstat (limited to 'src/i830_quirks.c')
-rw-r--r-- | src/i830_quirks.c | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/src/i830_quirks.c b/src/i830_quirks.c index f1a4d002..27e013b3 100644 --- a/src/i830_quirks.c +++ b/src/i830_quirks.c @@ -71,7 +71,10 @@ static void i830_dmi_store_##field(void) \ {\ FILE *f = NULL;\ f = fopen(DMIID_FILE(field), "r");\ - if (f == NULL) { i830_dmi_data[field] = NULL; return;}\ + if (f == NULL) {\ + xfree(i830_dmi_data[field]); i830_dmi_data[field] = NULL;\ + return;\ + }\ fread(i830_dmi_data[field], 64, 1, f);\ fclose(f);\ } @@ -95,7 +98,7 @@ I830_DMI_FIELD_FUNC(chassis_version); I830_DMI_FIELD_FUNC(chassis_serial); I830_DMI_FIELD_FUNC(chassis_asset_tag); -static int i830_dmi_scan(void) +static void i830_dmi_scan(void) { int i; @@ -103,9 +106,11 @@ static int i830_dmi_scan(void) i830_dmi_data[i] = xcalloc(64, sizeof(char)); if (!i830_dmi_data[i]) { int j; - for (j = 0; j < i; j++) + for (j = 0; j < i; j++) { xfree(i830_dmi_data[j]); - return -1; + i830_dmi_data[i] = NULL; + } + return; } } @@ -127,8 +132,6 @@ static int i830_dmi_scan(void) i830_dmi_store_chassis_version(); i830_dmi_store_chassis_serial(); i830_dmi_store_chassis_asset_tag(); - - return 0; } #define DMIID_DUMP(field) \ @@ -243,9 +246,9 @@ void i830_fixup_devices(ScrnInfoPtr scrn) { I830Ptr pI830 = I830PTR(scrn); i830_quirk_ptr p = i830_quirk_list; - int i, ret; + int i; - ret = i830_dmi_scan(); + i830_dmi_scan(); if (0) i830_dmi_dump(); @@ -259,8 +262,7 @@ void i830_fixup_devices(ScrnInfoPtr scrn) ++p; } - if (!ret) { - for (i = 0; i < dmi_data_max; i++) + for (i = 0; i < dmi_data_max; i++) + if (i830_dmi_data[i]) xfree(i830_dmi_data[i]); - } } |