Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp6553783ybx; Mon, 11 Nov 2019 10:51:29 -0800 (PST) X-Google-Smtp-Source: APXvYqy1QMMRNovLzkW4UuR/eH1Cb4ZWWuePYPyjHPtWSTHiGYLW905ntKdQP3zM9zTtMAV38SYB X-Received: by 2002:a05:6402:205c:: with SMTP id bc28mr27540856edb.124.1573498289495; Mon, 11 Nov 2019 10:51:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573498289; cv=none; d=google.com; s=arc-20160816; b=k9DmF4KRVuZtkoXBH8qygcoCZzb+KEollFwlC1nP5F5emDcsYn6yrQz3Ukn4XKOOqL 9p1ZgQUw6h420P6DAjbLVRltR7Jskk4TzZJmXCbC60kdQ9xN9ZxtGOCeHRImQ2FLXAW7 LSvr/h7iVC8z3FoM6iLGXD4aOEVbqREj5LaTQQcZkbAZLlV4ljUPBokezWyT0XfC4F8z hVepNJuwM2YDtT15MXIBph6AKEM3nEZ1ICgf/HM7Axn8cUIoxzi3cxxBfdvgbhTMqUbE 3PzJavADBCYCsyCKuelfrpOQ3G/tOehLciphl+Vr9LFh7xpeT7YXEKG0lLnns71Nawd2 xGdQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Yy9PFNDxuHWCMHlauN09WhlU2mBoxsmf1U3cpACJn10=; b=Kn+Ba2Jt5JAgXcJBaDO683lC2fnlrlzW452O//Dytvo/PEzwPDle1bM3S3IXts0HTC U8b5MkZ+pEovydW0EcPagm0Ai9+LIsyt1BuC8akV/gAU/xqVNHovuRWd2sVTHpgm8g6l FR1vfWGoqHirFcKTkO8Ibc8afoBWUapkHaVP9YtP6tD56cHoCx2xVPByRa8huXirOu3d daE1qlNMKL7/tboWSDmy3UyQfUUX+QC2gDoGTBjXZfkqJYErQHdPzv7y2Wrbj6MBK23q JWzSs4+ysezPs1GSma2BmQ521GD54of62qYmmHcs93xsepQS0rf++gHG5c3I6iomHXYd A3Pw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=oyl2EJ4O; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v9si12546784edl.90.2019.11.11.10.51.05; Mon, 11 Nov 2019 10:51:29 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=oyl2EJ4O; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730356AbfKKSuZ (ORCPT + 99 others); Mon, 11 Nov 2019 13:50:25 -0500 Received: from mail.kernel.org ([198.145.29.99]:44090 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728461AbfKKSuY (ORCPT ); Mon, 11 Nov 2019 13:50:24 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 213A321925; Mon, 11 Nov 2019 18:50:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1573498223; bh=EBAtvAhiCnY63HY/ZgVV2iM/wxrjmNUEcNHqp29LQQc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oyl2EJ4OxuPcuFL/6nR1PUPIXZNiqHLfED3QrhZHvbXkzvLaDdUpXfj8yGfNVPyxi qFcQVVLH+Zex/7X7vRkIpGEXfkqUaKnSG2DQBET3elrRDa6N8D+95RzgimDk5G28UX FcVvKbv2sFqlJmFPWZywJTC0ByJwgmeOFh3CCrB8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alexandru Ardelean , Stable@vger.kernel.org, Jonathan Cameron Subject: [PATCH 5.3 057/193] iio: imu: adis16480: make sure provided frequency is positive Date: Mon, 11 Nov 2019 19:27:19 +0100 Message-Id: <20191111181505.195564092@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191111181459.850623879@linuxfoundation.org> References: <20191111181459.850623879@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alexandru Ardelean commit 24e1eb5c0d78cfb9750b690bbe997d4d59170258 upstream. It could happen that either `val` or `val2` [provided from userspace] is negative. In that case the computed frequency could get a weird value. Fix this by checking that neither of the 2 variables is negative, and check that the computed result is not-zero. Fixes: e4f959390178 ("iio: imu: adis16480 switch sampling frequency attr to core support") Signed-off-by: Alexandru Ardelean Cc: Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/iio/imu/adis16480.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) --- a/drivers/iio/imu/adis16480.c +++ b/drivers/iio/imu/adis16480.c @@ -317,8 +317,11 @@ static int adis16480_set_freq(struct iio struct adis16480 *st = iio_priv(indio_dev); unsigned int t, reg; + if (val < 0 || val2 < 0) + return -EINVAL; + t = val * 1000 + val2 / 1000; - if (t <= 0) + if (t == 0) return -EINVAL; /*