Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp108214ybg; Mon, 8 Jun 2020 17:49:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwvi1Tci0y76FptVYg8OpYXOe2/75ySuYbS5URcM0jQ1eELe19iFmkG/kBDrSZFl5ue+qVU X-Received: by 2002:aa7:cdc6:: with SMTP id h6mr9546134edw.191.1591663775998; Mon, 08 Jun 2020 17:49:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591663775; cv=none; d=google.com; s=arc-20160816; b=Lo1+NsQH8xoR3CS9uSQXjRMNKlDrs4a4sSML9IMkX5RlvA4cPuMacJmzMv8JIzhS9i 1kdgMlYwhsC60rU9litgxGSaQX5TSUlEsZnnHlujKgBCqe4gU7Eq3A81XuvfwrGYSM9R DUhahJqd39OX/JdfZDCf02AMjk4AJKUdrEFBYOGPNq/abIKVVP2mTpYlvWgd+E7Wqnla o7pkTM3hTWbAG3NrJc5g/UQ5mc1E6pcrJ1lmNUkzJMcO+0SzxsrykbFndmmLu/ZJltwh +xTZe80Y1OVCCe0LKfASNjbL0OOiwW2lxG3rQCrVQnfpL38rvndzWt90flIZ498mnY2o 6Tkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Uxv3oSrR0VZUYr7ZOWuw1MbFLvh9sg3WslUvxYxKWnc=; b=LSCrsKCRnPsx4zpq2E7dbsSj/Ghn6YOicEkk3WF1fihD2vTmXuChWSeahTXH3NRvT2 KAmGF/jeNRZ5ic6oSk+xJ8ql9dyCokX5smaVvMOE4gpW/MKtirw6F46ah5b5chRuIs54 PkOa0+IC8o89py8iXKvKO0LLTzDXTH6KmAx/NO/lSfaD8JhnayoXc8Wnxq4t1F+eCDBG eg8yi1EyBx97vBFkyXPAmAxz4VW5X7ZkENOaFN3BuGNgxBeyxfBEjQSn+YBxydydpaZK neiJBGaAufXoolnKu4bMuI9BuMiWIz8FcnxT9LbSVoZPhf4C4ZjvLlj56wS0jdSUhpKq th0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=0oBRcgcs; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m10si9686255edv.322.2020.06.08.17.49.12; Mon, 08 Jun 2020 17:49:35 -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; dkim=pass header.i=@kernel.org header.s=default header.b=0oBRcgcs; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732697AbgFIApc (ORCPT + 99 others); Mon, 8 Jun 2020 20:45:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:58812 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728980AbgFHXLr (ORCPT ); Mon, 8 Jun 2020 19:11:47 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8E39720897; Mon, 8 Jun 2020 23:11:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591657907; bh=0ipDXHuXsr5Qaoa9TOtSQq6ymopP/5G4FnF3eZVMeJM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0oBRcgcs0ohMQ3MpCLGDKKA4oZC0aGcLW3N4mr9Yw6sKykb8Duz52c4JvhSgPdRCb 7CQSns8IjO+WsfTd6J8RC3MVuz1vQ4e6fXhFujdDm4LnoYrq5ZPrWr5sTWaNOcCASM nuO8PNCUDXZ0bfou5xQWYL7vvueCG8ob/Y9dkqnI= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Andy Shevchenko , Sasha Levin , platform-driver-x86@vger.kernel.org Subject: [PATCH AUTOSEL 5.7 259/274] platform/x86: hp-wmi: Convert simple_strtoul() to kstrtou32() Date: Mon, 8 Jun 2020 19:05:52 -0400 Message-Id: <20200608230607.3361041-259-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200608230607.3361041-1-sashal@kernel.org> References: <20200608230607.3361041-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Andy Shevchenko [ Upstream commit 5cdc45ed3948042f0d73c6fec5ee9b59e637d0d2 ] First of all, unsigned long can overflow u32 value on 64-bit machine. Second, simple_strtoul() doesn't check for overflow in the input. Convert simple_strtoul() to kstrtou32() to eliminate above issues. Signed-off-by: Andy Shevchenko Signed-off-by: Sasha Levin --- drivers/platform/x86/hp-wmi.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/platform/x86/hp-wmi.c b/drivers/platform/x86/hp-wmi.c index a881b709af25..a44a2ec33287 100644 --- a/drivers/platform/x86/hp-wmi.c +++ b/drivers/platform/x86/hp-wmi.c @@ -461,8 +461,14 @@ static ssize_t postcode_show(struct device *dev, struct device_attribute *attr, static ssize_t als_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { - u32 tmp = simple_strtoul(buf, NULL, 10); - int ret = hp_wmi_perform_query(HPWMI_ALS_QUERY, HPWMI_WRITE, &tmp, + u32 tmp; + int ret; + + ret = kstrtou32(buf, 10, &tmp); + if (ret) + return ret; + + ret = hp_wmi_perform_query(HPWMI_ALS_QUERY, HPWMI_WRITE, &tmp, sizeof(tmp), sizeof(tmp)); if (ret) return ret < 0 ? ret : -EINVAL; -- 2.25.1