Skip to content

Commit 01641b2

Browse files
andy-shevWolfram Sang
authored andcommitted
i2c: i801: Avoid memory leak in check_acpi_smo88xx_device()
check_acpi_smo88xx_device() utilizes acpi_get_object_info() which in its turn allocates a buffer. User is responsible to clean allocated resources. The last has been missed in the original code. Fix it here. While here, replace !ACPI_SUCCESS() with ACPI_FAILURE(). Fixes: 19b07cb ("i2c: i801: Register optional lis3lv02d I2C device on Dell machines") Signed-off-by: Andy Shevchenko <[email protected]> Reviewed-by: Pali Rohár <[email protected]> Reviewed-by: Jean Delvare <[email protected]> Signed-off-by: Wolfram Sang <[email protected]>
1 parent 689f535 commit 01641b2

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

drivers/i2c/busses/i2c-i801.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1194,19 +1194,28 @@ static acpi_status check_acpi_smo88xx_device(acpi_handle obj_handle,
11941194
int i;
11951195

11961196
status = acpi_get_object_info(obj_handle, &info);
1197-
if (!ACPI_SUCCESS(status) || !(info->valid & ACPI_VALID_HID))
1197+
if (ACPI_FAILURE(status))
11981198
return AE_OK;
11991199

1200+
if (!(info->valid & ACPI_VALID_HID))
1201+
goto smo88xx_not_found;
1202+
12001203
hid = info->hardware_id.string;
12011204
if (!hid)
1202-
return AE_OK;
1205+
goto smo88xx_not_found;
12031206

12041207
i = match_string(acpi_smo8800_ids, ARRAY_SIZE(acpi_smo8800_ids), hid);
12051208
if (i < 0)
1206-
return AE_OK;
1209+
goto smo88xx_not_found;
1210+
1211+
kfree(info);
12071212

12081213
*((bool *)return_value) = true;
12091214
return AE_CTRL_TERMINATE;
1215+
1216+
smo88xx_not_found:
1217+
kfree(info);
1218+
return AE_OK;
12101219
}
12111220

12121221
static bool is_dell_system_with_lis3lv02d(void)

0 commit comments

Comments
 (0)