summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZhenyu Wang <zhenyu.z.wang@intel.com>2008-02-19 21:13:45 +0800
committerJesse Barnes <jbarnes@hobbes.virtuousgeek.org>2008-02-22 11:51:05 -0800
commit5073b4026c536f6e5f0c8c5a741a1852b4480f31 (patch)
treec461dd31a0d06efa87d6fe293a0f85294ec73f27
parent3709962b91402027f2a73f732d1eb935f7d714b9 (diff)
downloadxorg-driver-xf86-video-intel-5073b4026c536f6e5f0c8c5a741a1852b4480f31.tar.gz
Don't leak memory if no DMI info is provided by kernel
-rw-r--r--src/i830_quirks.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/src/i830_quirks.c b/src/i830_quirks.c
index 32ec9ae8..875bf672 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) \
@@ -246,9 +249,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();
@@ -262,8 +265,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]);
- }
}