Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp99381pxj; Thu, 3 Jun 2021 01:44:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwwgsTP0Gt77JEKDapPun6KSzk733nnWgbKIRaq1JCspkqHT/u2dNZVF1lZU6/WlxP3kf5p X-Received: by 2002:a17:907:9801:: with SMTP id ji1mr11203446ejc.523.1622709883862; Thu, 03 Jun 2021 01:44:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622709883; cv=none; d=google.com; s=arc-20160816; b=iD5qeUE1xe+wBL1rgrahxg/qcpqTT2qUj1pTLt41diY5fYZ9Wcg0O8TPPqnwFtEb21 kHur+5Kj0Z9nC4s25kK3z96TnXQMch4xRcbx7TStEVk5bNiPcERMWxyjnb0Jcwy3LuYV /JopYN5cdiFRaagHoSCxc9mb8gxVuWeyDADpauIR4ZHm/P1geSFSEA4qBPNDt4mEz/5s gWpi76pI8KNkhfO0IGgKHtxA1Wb6uhdn9T73MzYvTpm69OUooVculVzCd2pLQfVs4PHj m/dfnBDSebTlZOO9Eh4CDTS+6EjO0+bfL6Hsjo2T/rPix96EUKk2SgdexlOTh5x4TIzT LMMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=FasBmmo3rMLUJTLP73Vw06fLeR5S5yl9ON6x7lOzzqI=; b=xIQnr4PKpN8XrHMRxpskPE50/ErWYCHHaCi51y8/KDec1vmu673K5S2Z0JWo7g782N B3oA0bqgY2E3B2BlACyw+HCJZ62QlKWvqsj807Z9xKF3citCK86jnR1K3njy1gh997Wy 5ATGbAjq5QHOblpEJJr3lvoPTobVHNPzYMS3QNtEWA7t3vK/IrtVtx4cZeZMrRR4T4AN jQInhexLDrdLmUBZGXOE7rR6nNcLqd4a1fqcsGBx/yzhie94LnoxhKG6avEAsI+F/WBY s81+bol+pZ5b8Y2oJVHUoV0Az9hvmOIor819o1JxcWfqgKTxECnFJ1l+Ve0vOE/7SlFd wU+g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z11si1752007eja.613.2021.06.03.01.44.21; Thu, 03 Jun 2021 01:44:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229786AbhFCIlX (ORCPT + 99 others); Thu, 3 Jun 2021 04:41:23 -0400 Received: from szxga08-in.huawei.com ([45.249.212.255]:4292 "EHLO szxga08-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229726AbhFCIlX (ORCPT ); Thu, 3 Jun 2021 04:41:23 -0400 Received: from dggemv704-chm.china.huawei.com (unknown [172.30.72.55]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4FwfMw71MMz1BHZH; Thu, 3 Jun 2021 16:34:52 +0800 (CST) Received: from dggpemm500009.china.huawei.com (7.185.36.225) by dggemv704-chm.china.huawei.com (10.3.19.47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Thu, 3 Jun 2021 16:39:36 +0800 Received: from huawei.com (10.175.113.32) by dggpemm500009.china.huawei.com (7.185.36.225) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Thu, 3 Jun 2021 16:39:35 +0800 From: Liu Shixin To: "Rafael J. Wysocki" , Len Brown CC: , , Liu Shixin Subject: [PATCH -next v2] ACPI: LPSS: Replaced simple_strtol() with kstrtol() Date: Thu, 3 Jun 2021 17:12:04 +0800 Message-ID: <20210603091204.355720-1-liushixin2@huawei.com> X-Mailer: git-send-email 2.18.0.huawei.25 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.113.32] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm500009.china.huawei.com (7.185.36.225) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The simple_strtol() function is deprecated in some situation since it does not check for the range overflow. Use kstrtol() instead. As the variables status and shared_host are valid only when the uid is not zero(default to zero). If uid_str is NULL or kstrtol() failed or uid is assigned to zero, related operations can be skipped. Signed-off-by: Liu Shixin --- v1->v2: The previous description is inaccurate, so modified it. drivers/acpi/acpi_lpss.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/acpi/acpi_lpss.c b/drivers/acpi/acpi_lpss.c index ca742f16a507..1b46e00cad3a 100644 --- a/drivers/acpi/acpi_lpss.c +++ b/drivers/acpi/acpi_lpss.c @@ -186,13 +186,12 @@ static void byt_i2c_setup(struct lpss_private_data *pdata) long uid = 0; /* Expected to always be true, but better safe then sorry */ - if (uid_str) - uid = simple_strtol(uid_str, NULL, 10); - - /* Detect I2C bus shared with PUNIT and ignore its d3 status */ - status = acpi_evaluate_integer(handle, "_SEM", NULL, &shared_host); - if (ACPI_SUCCESS(status) && shared_host && uid) - pmc_atom_d3_mask &= ~(BIT_LPSS2_F1_I2C1 << (uid - 1)); + if (uid_str && !kstrtol(uid_str, 10, &uid)) { + /* Detect I2C bus shared with PUNIT and ignore its d3 status */ + status = acpi_evaluate_integer(handle, "_SEM", NULL, &shared_host); + if (ACPI_SUCCESS(status) && shared_host && uid) + pmc_atom_d3_mask &= ~(BIT_LPSS2_F1_I2C1 << (uid - 1)); + } lpss_deassert_reset(pdata); -- 2.18.0.huawei.25