Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp963558imm; Sat, 11 Aug 2018 03:29:13 -0700 (PDT) X-Google-Smtp-Source: AA+uWPxJFqHPM1AOidUuIECqa+M2cNRYIJumd9E6Y9XyfoUJ8xGZwzLXcpP/YxOvx18QXkogDRVS X-Received: by 2002:a63:a011:: with SMTP id r17-v6mr9522765pge.90.1533983353473; Sat, 11 Aug 2018 03:29:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533983353; cv=none; d=google.com; s=arc-20160816; b=ZHyukxHGtbWGslzCOgBaQpYj5LIGcC4uCUAJg9/f6OE09qxJ7yyQIWpDw/d6qA8B24 NtLMyOytmKFyIoNojH/1jHAEmbkGCTQ9u5dplpf4t+s1TNZexVcF1W8BmysI+A8x40Ff u4XqWcRUQPcnKHV7y3Rsg9LwL4/LmmRPjQap8uhmq+jmNPf+80qp+N/fyjqwjY/CTfhT /ZuC0PxUkQXwV35sGhHV+BKEbadIsNPYrw02ziFbMP1cRTPkZ5+sBfkbuHJS6EF+QS0J CE0DjF+Ll+mBC5N3/ahG2t2skYG+Xc/EQtZBtq2D0WTlPCjceSqxQBEkP3TdQcrcEmAc 6DKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=ZQShvBK2SpYMU2qzPWJmBLbnquryN45IeArdF60JAf0=; b=BBdX95K601+GSqXhi+sVjMg/aPw3hes8eVPkAMlNqLaLzPrEC5gSwWEXDjyNsJOjCi DyJEDKOAuj3fvw4Tg/uBn5M/+Etqyw9185VVgQswwcw+HXkFV9958M8cnJt0Bb84u4aD 8ehBBNMpkuWnSV4+VhQkaqo2XBktW2vK97IsrgJG76pKY6LQQbj+sSoR8CYmuSN91pYi 5TNEhFHTQJvN8xkReIm39Sk5Pd2n5rJpQGiZZzae/iRG72C2Sk4o0e/9m+kdnDi9KPHV 5ma2yMk7C5MmjF14U/rw/8qsHOKLe0FXgzZ0MxM2Gh+DGpWRJqnjI19C9jDT2mXL0fai iMXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=qlKSKDhP; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g12-v6si10990722pfh.346.2018.08.11.03.28.46; Sat, 11 Aug 2018 03:29:13 -0700 (PDT) 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=@gmail.com header.s=20161025 header.b=qlKSKDhP; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727304AbeHKNBJ (ORCPT + 99 others); Sat, 11 Aug 2018 09:01:09 -0400 Received: from mail-pl0-f65.google.com ([209.85.160.65]:44684 "EHLO mail-pl0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727235AbeHKNBI (ORCPT ); Sat, 11 Aug 2018 09:01:08 -0400 Received: by mail-pl0-f65.google.com with SMTP id ba4-v6so5027091plb.11; Sat, 11 Aug 2018 03:27:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=ZQShvBK2SpYMU2qzPWJmBLbnquryN45IeArdF60JAf0=; b=qlKSKDhPuc6cXA+FaAa9lWF4TkWVnxcVlkEDC7oThE9MJHWJrSIDQAukIwAbTtWMkn LmRJllD3fQFEWyB7XVWy5vDKPzRNF3/AmdB3PgwcCBo6rxx3z9Rd4lXNkvTNGHD0dccg sqfL4q6GxZXjAnxSNFZdXpFrnbDlr4hc0wxQKrW6uQu4bD10MbCagZhX368mZXOLxpXK mTZ/U4euvF762rnkPmnJmqFtdKT8qggNPC/BDe/m1RpWfA7unCi57GoQ+FCu6uVp+zW7 eizwf8MojeGjjAFo8eSGcDN/UL5emASeWlplF6+QR9BFVAQ5tYxAX6gBB2Ghgz2yrS3B b/9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=ZQShvBK2SpYMU2qzPWJmBLbnquryN45IeArdF60JAf0=; b=BOtmyLEzXaF7AKVDnJzZjMQkCOJ6c8dTPtSTXuexCB++8clkml2RuJ9OAmxWmmE5EP nWrg+9mEjzdFwNBtzjh4SDrS2MFsAJtHaCc/Sqq+qQvI/Yf9Q9RVdgutRkN/SOZrcWes pi8DHgo7gaGPvewxR8UC7+TTR1gg6dBjxn0WlEKL08gcwXniit5bv+uZWhx5y53gvTla L8U3O54c/jPNB6BBxVaHjo1sMwnpDsF7SHsN2VaTnhbXPxEBI9/4MfweVrB0NeGAKQzW xSWfaU5I8JOm3da4vBq8uryo005zSp0n8ths2O/mHSwO2sSTexXsViWdag0hIwJVX/R3 lxmg== X-Gm-Message-State: AOUpUlGcvQLSon+bypmzup48MYn8rdVIuXOdolLhJdqrH7BTurcaE8Xq E1TQgcXscEWHMce+Q1vN0so= X-Received: by 2002:a17:902:b81:: with SMTP id 1-v6mr9644886plr.164.1533983242516; Sat, 11 Aug 2018 03:27:22 -0700 (PDT) Received: from localhost.localdomain ([103.233.116.134]) by smtp.gmail.com with ESMTPSA id m26-v6sm31373079pfi.102.2018.08.11.03.27.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 11 Aug 2018 03:27:21 -0700 (PDT) From: Himanshu Jha To: jic23@kernel.org Cc: dpfrey@gmail.com, daniel.baluta@gmail.com, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Himanshu Jha Subject: [PATCH] iio: chemical: bme680: Add check for val2 in the write_raw function Date: Sat, 11 Aug 2018 15:56:36 +0530 Message-Id: <20180811102636.6171-1-himanshujha199640@gmail.com> X-Mailer: git-send-email 2.17.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org val2 is responsible for the floating part of the number to be written to the device. We don't need the floating part while writing the oversampling ratio for BME680 since the available oversampling ratios are pure natural numbers. So, add a sanity check to make sure val2 is 0. Signed-off-by: Himanshu Jha --- drivers/iio/chemical/bme680_core.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/iio/chemical/bme680_core.c b/drivers/iio/chemical/bme680_core.c index 7d9bb62baa3f..9d5a05e054d1 100644 --- a/drivers/iio/chemical/bme680_core.c +++ b/drivers/iio/chemical/bme680_core.c @@ -852,6 +852,9 @@ static int bme680_write_raw(struct iio_dev *indio_dev, { struct bme680_data *data = iio_priv(indio_dev); + if (val2 != 0) + return -EINVAL; + switch (mask) { case IIO_CHAN_INFO_OVERSAMPLING_RATIO: switch (chan->type) { -- 2.17.1