Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp5078015pxj; Wed, 26 May 2021 02:14:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw/v58ZhFH8xM7S7L0H2xKxj7EWn77iDe2lFtrm5OHjioWrsYD9dIoP+EFVvXAOEPnhittf X-Received: by 2002:a05:6402:5194:: with SMTP id q20mr1862258edd.356.1622020447591; Wed, 26 May 2021 02:14:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622020447; cv=none; d=google.com; s=arc-20160816; b=VYCSIPiz6f6v8ONBY49oN5i5WW23XJf9HsOEtWyrPma63flk8iPzJtS7Uh1jkGjouK ULL22KhHbyw960H1L+Q5GUQhcG0LWyldP/lNMk5E1QeN5+J0OM0CBYWjv1Z3zVEdrAlY oMVVl9QmhhhQH6xV+P/r8j/Sw66Xi3JECGRq3DCrBvnkkO45vF2gXZmBLJWqAXJ+UsJL iJhJrFO5JwERCVP/dvw6RiaQdRLHsxQZpCV89b55AdjjjzmC/eE2kd2EV6/CTlVF4Y5b 0Udqvsd2rD0Exkf3NmVxIjW0U4vTYnknnnCSpCdJK5Ef4gjgam8xdV/N7dqk43yO/2H2 LfNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=e/3BplGm+4+vVem3X26+gTss/jwyF9Ek9igQS6OE1fM=; b=jHw0WJU4JXmuSnuznjrV5uuiloatrSx+l+VuOOoEZ//9G4F/DfBqI74kvt9rjRc6qk mXj0zZDuugFyykFcX1vtYqk9CPFnaN9tnv75nmrHjVDgvXeHdRcap4qfv2ucwoAveD24 V/jY7g/Q7lGcw51Rk2cbpzKoIrGImbdDBMxmqcPFoMsSaHmPpQHOQrhrkebrl8h3ducI IFdt9ePurQeXsXH0bi45WfvvscK/jFNt8aHz2tvIPh7pmL+xymJ36p0+/ahu6c8O/X+P ZvzuElmxBoS/5OSrrjhx9G3u99krk/LMG3dddaRwQHPtOw+l5OBDAO83AC2hqU6e0wmc eblQ== 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 dh18si18055658edb.392.2021.05.26.02.13.43; Wed, 26 May 2021 02:14:07 -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 S233646AbhEZJLz (ORCPT + 99 others); Wed, 26 May 2021 05:11:55 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:6639 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233412AbhEZJLy (ORCPT ); Wed, 26 May 2021 05:11:54 -0400 Received: from dggems701-chm.china.huawei.com (unknown [172.30.72.58]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4FqlTG3KXMz1BQTF; Wed, 26 May 2021 17:07:30 +0800 (CST) Received: from dggema756-chm.china.huawei.com (10.1.198.198) by dggems701-chm.china.huawei.com (10.3.19.178) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2176.2; Wed, 26 May 2021 17:10:22 +0800 Received: from localhost.localdomain (10.175.112.125) by dggema756-chm.china.huawei.com (10.1.198.198) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Wed, 26 May 2021 17:10:21 +0800 From: Chen Huang To: Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , "Boris Ostrovsky" , Juergen Gross , Stefano Stabellini , Mark Fasheh , Joel Becker , Joseph Qi , Nathan Lynch , Andrew Donnellan , Alexey Kardashevskiy , Andrew Morton , Stephen Rothwell , "Jens Axboe" , Yang Yingliang , "Masahiro Yamada" , Dan Carpenter CC: , , , , Chen Huang Subject: [PATCH -next 2/3] xen: balloon: Replaced simple_strtoull() with kstrtoull() Date: Wed, 26 May 2021 09:20:19 +0000 Message-ID: <20210526092020.554341-2-chenhuang5@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210526092020.554341-1-chenhuang5@huawei.com> References: <20210526092020.554341-1-chenhuang5@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggema756-chm.china.huawei.com (10.1.198.198) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The simple_strtoull() function is deprecated in some situation, since it does not check for the range overflow, use kstrtoull() instead. Signed-off-by: Chen Huang --- drivers/xen/xen-balloon.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/xen/xen-balloon.c b/drivers/xen/xen-balloon.c index a8d24433c8e9..1fba838963d2 100644 --- a/drivers/xen/xen-balloon.c +++ b/drivers/xen/xen-balloon.c @@ -163,13 +163,16 @@ static ssize_t store_target_kb(struct device *dev, const char *buf, size_t count) { - char *endchar; + ssize_t ret; unsigned long long target_bytes; if (!capable(CAP_SYS_ADMIN)) return -EPERM; - target_bytes = simple_strtoull(buf, &endchar, 0) * 1024; + ret = kstrtoull(buf, 0, &target_bytes); + if (ret) + return ret; + target_bytes *= 1024; balloon_set_new_target(target_bytes >> PAGE_SHIFT); -- 2.25.1