Skip to content

Commit 8e3ecc6

Browse files
Liu Shixinrafaeljw
authored andcommitted
ACPI: LPSS: Use kstrtol() instead of simple_strtol()
The simple_strtol() function is not reliable in some situation, since it does not check for the range overflow. Use kstrtol() instead. While at it, modify the code to avoid evaluating _SEM unnecessarily if uid_str is NULL or kstrtol() fails to convert that string to a nonzero number. Signed-off-by: Liu Shixin <[email protected]> [ rjw: Check uid right after calling kstrtol() ] [ rjw: Rewrite subject and changelog ] Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent 614124b commit 8e3ecc6

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

drivers/acpi/acpi_lpss.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -186,13 +186,12 @@ static void byt_i2c_setup(struct lpss_private_data *pdata)
186186
long uid = 0;
187187

188188
/* Expected to always be true, but better safe then sorry */
189-
if (uid_str)
190-
uid = simple_strtol(uid_str, NULL, 10);
191-
192-
/* Detect I2C bus shared with PUNIT and ignore its d3 status */
193-
status = acpi_evaluate_integer(handle, "_SEM", NULL, &shared_host);
194-
if (ACPI_SUCCESS(status) && shared_host && uid)
195-
pmc_atom_d3_mask &= ~(BIT_LPSS2_F1_I2C1 << (uid - 1));
189+
if (uid_str && !kstrtol(uid_str, 10, &uid) && uid) {
190+
/* Detect I2C bus shared with PUNIT and ignore its d3 status */
191+
status = acpi_evaluate_integer(handle, "_SEM", NULL, &shared_host);
192+
if (ACPI_SUCCESS(status) && shared_host)
193+
pmc_atom_d3_mask &= ~(BIT_LPSS2_F1_I2C1 << (uid - 1));
194+
}
196195

197196
lpss_deassert_reset(pdata);
198197

0 commit comments

Comments
 (0)