From patchwork Fri Nov 16 22:51:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shreeya Patel X-Patchwork-Id: 10687107 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 7E1E213B5 for ; Fri, 16 Nov 2018 22:51:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6BF322CBEA for ; Fri, 16 Nov 2018 22:51:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5C3D42CC1A; Fri, 16 Nov 2018 22:51:40 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 010642CBEA for ; Fri, 16 Nov 2018 22:51:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726607AbeKQJFy (ORCPT ); Sat, 17 Nov 2018 04:05:54 -0500 Received: from mail-pf1-f193.google.com ([209.85.210.193]:39882 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725995AbeKQJFy (ORCPT ); Sat, 17 Nov 2018 04:05:54 -0500 Received: by mail-pf1-f193.google.com with SMTP id c72so7373819pfc.6; Fri, 16 Nov 2018 14:51:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id; bh=OwHcst+enILOIrmgfby8FDaIChOrcGZVIxgWGuwQJZI=; b=fhTFvyiamH4EGxbnSXyG3JpZ/JBP3STklHfIMitnqr5oTszVyRaxmHSQcCykJvOBqh dQGqM7vWiapOwwMcqg993RUvn4gvR4FEP2EupK5fgA9pUWYilizKgPHdyuEFjOnaPSwD KdL6Zd6pLKQwYk0eSMZ2wERA5wzf5BA55nEV+Td3vfFrlubPw7tMb+sgoET6SuUCvklB iC9ADUjIyA6Y2fn4UQLEixH37m40KQvEKMb5+d1zni2cdr6JCbZUfMw6bvxFHjGg6ca+ 8oJZqhle5ylkC13k3P091wmWQ50c7d55KStG9gSh2d/ZFSFd39TlhwWaEniLHKo1HNkK YbQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id; bh=OwHcst+enILOIrmgfby8FDaIChOrcGZVIxgWGuwQJZI=; b=PJ8O9o3K+qpkWs4zeheXNPnFAUMEAPC3lqRwyzsgxWBL31T8r4Q1X1PuIs7zaqDaVR wA9hT5now5uI1sTwPWp17JIsdKjOCYRegPQxxnXVfHuXAp5FdovnSK/ClLhWde087l+1 88BV+KN1lcWhEoB/cUVt0jqLYpBEvlHsIuT5t5yLZJJnqwoH1QwMpqpT+cUbE2NOUMWj DncEzAiY+onWaKIilJpmrsE77tzIkpREUuOBe2MGnWQczGjtwAst7n3AbsiIbzaKFMAc Qw/876rTldr/HHZ6Ghw0q+Vvkp8XQAnMTuW9ewhilLsVKrV0OMCBO3lRaF7MXiEpT8+/ cEdA== X-Gm-Message-State: AGRZ1gKMHEXzrp9nzde+UW/TqdWOPPjQRItQiiE2DzgUBEYbmoizI07c rNgPGJomXVQ8K9FJleMjo/M= X-Google-Smtp-Source: AJdET5eXpe8zD0VAjobO2dAI69cHXfF4WKLOS1vSatOQXdxpU9T4phi3NMZbDgn80/NuWN4zSjXAKg== X-Received: by 2002:a63:4e41:: with SMTP id o1mr11889942pgl.282.1542408698201; Fri, 16 Nov 2018 14:51:38 -0800 (PST) Received: from localhost.localdomain ([103.212.140.154]) by smtp.gmail.com with ESMTPSA id 34sm47407359pgp.90.2018.11.16.14.51.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 16 Nov 2018 14:51:37 -0800 (PST) From: Shreeya Patel To: lars@metafoo.de, Michael.Hennerich@analog.com, jic23@kernel.org, knaack.h@gmx.de, pmeerw@pmeerw.net, gregkh@linuxfoundation.org, linux-iio@vger.kernel.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/7] Staging: iio: adt7316: Add an extra check for 'ret' equals to 0 Date: Sat, 17 Nov 2018 04:21:32 +0530 Message-Id: <20181116225132.24459-1-shreeya.patel23498@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 ret = 0 indicates a case of no error but no data read from the bus which is an invalid case. This case doesn't ever happen in reality. It should perhaps be handled for correctness though. Signed-off-by: Shreeya Patel --- drivers/staging/iio/addac/adt7316-i2c.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/staging/iio/addac/adt7316-i2c.c b/drivers/staging/iio/addac/adt7316-i2c.c index 856bcfa60c6c..473e5e34ec00 100644 --- a/drivers/staging/iio/addac/adt7316-i2c.c +++ b/drivers/staging/iio/addac/adt7316-i2c.c @@ -30,6 +30,10 @@ static int adt7316_i2c_read(void *client, u8 reg, u8 *data) } ret = i2c_smbus_read_byte(client); + + if (!ret) + return -EIO; + if (ret < 0) { dev_err(&cl->dev, "I2C read error\n"); return ret;