Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3340876pxj; Mon, 24 May 2021 04:38:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzyZKejnDN0AbCOxXVxbwzsx8RiZsCpmw6c/S5J4Np4pyxOGQaeuBYRvNarBypupMAF5YQp X-Received: by 2002:a17:906:c0da:: with SMTP id bn26mr5009268ejb.437.1621856280998; Mon, 24 May 2021 04:38:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621856280; cv=none; d=google.com; s=arc-20160816; b=VRX5qczUYmFiSR1Ccm48ZzboGC/viqRCox8UdAxfXNA188P2EAlF2yBVYVc2oMhhES d2L8G0jc8OUO3jkJt7JqhEYOVso08KVovDaqZPZ3X90DXs0bJSv7HvEDQTDMBxplyZKI rpNMszDb8NWim6BkVe7IkMLio67gOCPc4d/NGIG83+9W+u3zxR/WHKYn1yFodKFDdW84 vsA83nFXaM9uVhcsvWpeyTtUFExLLcQnSIP9/N6bCudRieesNMVtqoNWj66c+Q7n8iLw dU/3/xiTXVmoB4DE7ZAybG8yscG8xAatdxJD2ohWOSnIUoDA97gEwH2YEyfvwaDxGhiL DSKg== 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=E9fXR2jfr7XlI20efA5Ch0jwDLFL1wOrLXkqtd98uIk=; b=gMFGhfrF7KDBRZ1R1BfEVp/UjM3jF3z6Xl8rqCW4Xf1UkbSIltTZK1woc7ZEwHolec GolRYB8Uogdi3OeOERflHk1rPcQYn/EmqkU1SgAbpLHiIVFpXEJ4+jT/ovFTRx0ls9+T ID+/LoS8ze4YoFs2qcDhytsUVod1IWu+RfNAR+iXZIqFcO0b7BRuLoHKt9/rAKfgLiuK voliFsxDwqCyNpoWaUwGgNwk7S33ySaJ5Mn3/ZGsTiLXVH/VbA2DaVZvKvhVHaIfEihp 6Sdm2dAB32JZ9UFLfph+zgV1vUfnqQTZFZv68JZEnW9I013LS0aMqdKbSb4Jz2mk3U5w QYhg== 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 hh21si12942138ejb.473.2021.05.24.04.37.38; Mon, 24 May 2021 04:38:00 -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 S232730AbhEXLhQ (ORCPT + 99 others); Mon, 24 May 2021 07:37:16 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:3645 "EHLO szxga05-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232690AbhEXLhL (ORCPT ); Mon, 24 May 2021 07:37:11 -0400 Received: from dggems705-chm.china.huawei.com (unknown [172.30.72.59]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4FpZn32z1VzNybK; Mon, 24 May 2021 19:32:07 +0800 (CST) Received: from dggpemm500009.china.huawei.com (7.185.36.225) by dggems705-chm.china.huawei.com (10.3.19.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Mon, 24 May 2021 19:35:42 +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; Mon, 24 May 2021 19:35:42 +0800 From: Liu Shixin To: Colin Leroy CC: , , "Liu Shixin" Subject: [PATCH -next] macintosh/therm_adt746x: Replaced simple_strtol() with kstrtoint() Date: Mon, 24 May 2021 20:08:35 +0800 Message-ID: <20210524120835.1580420-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 kstrtoint() instead. Signed-off-by: Liu Shixin --- drivers/macintosh/therm_adt746x.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/macintosh/therm_adt746x.c b/drivers/macintosh/therm_adt746x.c index 7e218437730c..0d7ef55126ce 100644 --- a/drivers/macintosh/therm_adt746x.c +++ b/drivers/macintosh/therm_adt746x.c @@ -352,7 +352,8 @@ static ssize_t store_##name(struct device *dev, struct device_attribute *attr, c struct thermostat *th = dev_get_drvdata(dev); \ int val; \ int i; \ - val = simple_strtol(buf, NULL, 10); \ + if (unlikely(kstrtoint(buf, 10, &val)) \ + return -EINVAL; \ printk(KERN_INFO "Adjusting limits by %d degrees\n", val); \ limit_adjust = val; \ for (i=0; i < 3; i++) \ @@ -364,7 +365,8 @@ static ssize_t store_##name(struct device *dev, struct device_attribute *attr, c static ssize_t store_##name(struct device *dev, struct device_attribute *attr, const char *buf, size_t n) \ { \ int val; \ - val = simple_strtol(buf, NULL, 10); \ + if (unlikely(kstrtoint(buf, 10, &val)) \ + return -EINVAL; \ if (val < 0 || val > 255) \ return -EINVAL; \ printk(KERN_INFO "Setting specified fan speed to %d\n", val); \ -- 2.18.0.huawei.25