From patchwork Sat Aug 11 10:26:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Himanshu Jha X-Patchwork-Id: 10563395 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9F2A81057 for ; Sat, 11 Aug 2018 10:27:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 920582A26E for ; Sat, 11 Aug 2018 10:27:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 859B02A37E; Sat, 11 Aug 2018 10:27:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_WEB autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3B06E2A26E for ; Sat, 11 Aug 2018 10:27:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727249AbeHKNBJ (ORCPT ); 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-Google-Smtp-Source: AA+uWPzOqEgY4ec+ik10SzcOUyKiPoL/3i7ijoDTg8sLeJBKRSiW6EvhdI70FNqqWg2jwBDcyeW50g== 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-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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) {