Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3340266pxj; Mon, 24 May 2021 04:37:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxKByoLufjecnh7yDGToTM6lHUm9HEXWzLjnCs9v0C9wNEZXwT63pN4xBIYlRFmkku1bOWu X-Received: by 2002:a05:6402:2207:: with SMTP id cq7mr24736728edb.216.1621856223516; Mon, 24 May 2021 04:37:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621856223; cv=none; d=google.com; s=arc-20160816; b=Q+/DBv2rmryKBHcpReApBgEq8Md6STjgLmkyszIUlBjA0h04xlkIgimm+dM6uLSODN ky6DqwVHg/o13c/S//2LcJ3XiE0xIiC03eW3B0xX+K0qVhRQThesoAsv627N6qvoPe4I P0GWshd3VDqOfTTZ/gFmzzamU1jAMbV0sW0jek7dQsQWxODcswJTyjvlKTOa23TFwFqx oKbrc/I795gN+ebjDRymKLXas75zf48RgqBPeU52EafhgZUajaqjZ0YQaPhxzR543hiY 9oYEVV+T4jjGIAYuQ/9SII91MijoIxkBcndtlmhO5Q/0vRZlQ6bKga1MiF2RhRS7tz5k EX5A== 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=uxhW9/vDIqKT6QbGCeq7bb754/I08a1eLV90jcKnrGY=; b=IZHeY3qhasVCWyjN3JQrbC17mKT2+zqlIg+xk1p6wyvxEk8kaZL2RZJbEEChzMCubG n6xWgkGKTI3/8VRdxAm2NwSY4ilOpr8046YhGUBrTEZKqAXztJ+c78LiXlUOyIW6906R HU5acJtS9zd7XKj6Fg/a5i1AHbe2bPXvb9retcv1P4LItJ+vW4yKZvQrVB+/9t2odltX 66xpmMpPhmig3N2xgMkxe8WcUp/qBw+nXe8ak5gNjvUZRm39rDG2u0hS6U7NvpgNtUUe Of8fvLQV3e1w3XwURpGkt3lfjkFMWoI8j8whjSCfN8xkl+qQz4yuNm26M3QPm/wZqx03 vwfg== 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 c6si11749968ede.388.2021.05.24.04.36.40; Mon, 24 May 2021 04:37:03 -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 S232708AbhEXLhM (ORCPT + 99 others); Mon, 24 May 2021 07:37:12 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:5755 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232070AbhEXLhJ (ORCPT ); Mon, 24 May 2021 07:37:09 -0400 Received: from dggems702-chm.china.huawei.com (unknown [172.30.72.59]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4FpZn14ldCzmkgb; Mon, 24 May 2021 19:32:05 +0800 (CST) Received: from dggpemm500009.china.huawei.com (7.185.36.225) by dggems702-chm.china.huawei.com (10.3.19.179) 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:40 +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:40 +0800 From: Liu Shixin To: Jens Axboe CC: , , Liu Shixin Subject: [PATCH -next] block: Replaced simple_strtol() with kstrtoint()/kstrtoul() Date: Mon, 24 May 2021 20:08:33 +0800 Message-ID: <20210524120833.1580295-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()/kstrtoul() instead. Attention, if the end of the input string isn't '\n', simple_strtol() will ignore following characters and return the value but kstrtoint()/kstrtoul() will return an error code. Signed-off-by: Liu Shixin --- drivers/block/brd.c | 3 +-- drivers/block/loop.c | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/block/brd.c b/drivers/block/brd.c index 7562cf30b14e..5b43f6b2d506 100644 --- a/drivers/block/brd.c +++ b/drivers/block/brd.c @@ -358,8 +358,7 @@ MODULE_ALIAS("rd"); /* Legacy boot options - nonmodular */ static int __init ramdisk_size(char *str) { - rd_size = simple_strtol(str, NULL, 0); - return 1; + return !kstrtoul(str, 0, &rd_size); } __setup("ramdisk_size=", ramdisk_size); #endif diff --git a/drivers/block/loop.c b/drivers/block/loop.c index d58d68f3c7cd..9fe595afa9cf 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -2415,8 +2415,7 @@ module_exit(loop_exit); #ifndef MODULE static int __init max_loop_setup(char *str) { - max_loop = simple_strtol(str, NULL, 0); - return 1; + return !kstrtoint(str, 0, &max_loop); } __setup("max_loop=", max_loop_setup); -- 2.18.0.huawei.25