Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp1021413imd; Sat, 3 Nov 2018 15:52:23 -0700 (PDT) X-Google-Smtp-Source: AJdET5cArypIUIM7bx3qCAVwhdUISRHOfdhZPLruVVgzgGw8IXslo7z+lkpzwRiIaSmW+LW3Okma X-Received: by 2002:a65:6684:: with SMTP id b4mr15485305pgw.55.1541285543904; Sat, 03 Nov 2018 15:52:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541285543; cv=none; d=google.com; s=arc-20160816; b=pAWG1rZYSXHrJ9d1HE4am0JfdQGCtZIubTSwftBG5LMPicTBezxtm3Kllj0WgBkcRJ MrA29U2Z7sQZ6NuIpV2E0My6YBw7jIN0xFqrcmkppGzaXGcnmLqBTIZForH/IIlNtJc9 8nHgWPCBtajTtH/s19xtpLHiV44VJqY48qvKVD/zOohWUWVzgPvEqAQLMj2gqVPGEkFR B3EW4YgBt6qpAjhCuo0qWdgd3Wy8rqT2lFvwvABY9/oN1WUVAGLNFS8mfx2Me93+3DL2 mvXMwzyKQAAvU20COCUC5gY4VrQRrW9DYkWU9y6UHGpPAuPRYM61CclU2OVUZtOa+WkC jxNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=uRaFpWiqq0590LAIWCKDCZV7Qjo+FL/9V7eRidlfT3s=; b=IqejxuKv1DPZ/AyJ2nqhg/LVBGwBKyogBhLGWVN+U0/TYR8r5aZIWjtZu5LCsr5LKu CxFyFkOSkVk+VLRjYrIZ2z0jA8Fzjy9eB4DQ0JX6lwM66WmhWZHRubJn8NtnwXfqRtlR 1bEyfKAGAckfWo8TQbgzJsimCOh3zjxHtidR2VG7NX0AjPelnZR/s9MYQH6EJ+p2dZEP qipuncwcNi6LB5qDmwB/9fBlIQvtWJvXd6lMFUFTa1xc7bmkbz2saJXZGBo7E5XhLPyD ix+866FuOLgE+TkfFu1s1E8Xm+5+uSdeyZsGjxRgOr/8qwGGILdTvv5vStsiQjOfPgHh R29w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@usp-br.20150623.gappssmtp.com header.s=20150623 header.b=1CtKVcdx; 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=fail (p=NONE sp=NONE dis=NONE) header.from=usp.br Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v35si5299367pgl.130.2018.11.03.15.52.09; Sat, 03 Nov 2018 15:52:23 -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=@usp-br.20150623.gappssmtp.com header.s=20150623 header.b=1CtKVcdx; 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=fail (p=NONE sp=NONE dis=NONE) header.from=usp.br Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728847AbeKDIDH (ORCPT + 99 others); Sun, 4 Nov 2018 03:03:07 -0500 Received: from mail-qk1-f195.google.com ([209.85.222.195]:41425 "EHLO mail-qk1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726990AbeKDIDG (ORCPT ); Sun, 4 Nov 2018 03:03:06 -0500 Received: by mail-qk1-f195.google.com with SMTP id 189so8946275qkj.8 for ; Sat, 03 Nov 2018 15:50:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=usp-br.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=uRaFpWiqq0590LAIWCKDCZV7Qjo+FL/9V7eRidlfT3s=; b=1CtKVcdxkcaI283xQLfB0FmveXFcTjA/J4RM6cOTw0TWTWyYJxs1hfN4KODCcC4rs4 PdacCMMokO7XCZmntj9zaKaRwMHeTKdUb75OZ+DR6cLWhnvxiK85DN2A1b31MEVefbgu X3MhEvXnjvs0IODEaQ8wOx2wPIe50dn+iJY3G7+T49qRBFrcJYJjiQQOG7CM7zrq8jMC 20DpfgzBZhpwwx/Pxdv4D4CNz3FcYgZ0D5jLK6qEq4cDs7+4eQnNg84gUI067LCdP2CL OfZsA447baszPcwSqb2UbHrxngRNGF+sXEjoTcONlbi6TKC4DJvyOWuXWEPYWPwmRXf9 ZmVw== 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:in-reply-to :references; bh=uRaFpWiqq0590LAIWCKDCZV7Qjo+FL/9V7eRidlfT3s=; b=ihlrzYlSE4Qh+yu4Oas4CVtoEE5d2A3JahUr9IK5bf87XUeUTj07L0y8TX0DXcS+Xq jy/if6Ib+5aPHnHKtMPjO3hQ+mta3fgVbl9iZE0gEkLX9LwMRTyaDpBxOFBEbq/J1+5P mBmuRv3cXZbFi9yTXctJ72Q9Ks1/QJRC6ogGunAKcVRMsOwplhPvvqCeCowV2Dhc1pL2 +/i3jhp6t+ueLNoH+8AVtWdxIuIKsCRHcx0w9KJ8TeJSLnxYpAmVUNLbHlVfQSvxAIEk bvF/Z1ElDagFHmukPhVlJa9gGPIvHBabLj7lmd5q0cEto0A4JXVTXlywpsi42uLDsOTH bTIA== X-Gm-Message-State: AGRZ1gJfb84NoDIv5R1hySSBsD7LqIKajSfPYahzAAH4cw2nmGDIOFZn Z7OM9WTwsdJHwUznNYk4r2ujlg== X-Received: by 2002:a0c:d107:: with SMTP id a7mr16112704qvh.104.1541285425687; Sat, 03 Nov 2018 15:50:25 -0700 (PDT) Received: from mango.spo.virtua.com.br ([2804:14c:81:942d::1]) by smtp.gmail.com with ESMTPSA id 35-v6sm27550924qtu.69.2018.11.03.15.50.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 03 Nov 2018 15:50:25 -0700 (PDT) From: Matheus Tavares To: Lars-Peter Clausen , Michael Hennerich , Jonathan Cameron , Hartmut Knaack , Peter Meerwald-Stadler , Greg Kroah-Hartman Cc: linux-iio@vger.kernel.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, kernel-usp@googlegroups.com Subject: [PATCH v3 6/6] staging:iio:ad2s90: Check channel type at read_raw Date: Sat, 3 Nov 2018 19:49:48 -0300 Message-Id: <20181103224948.31014-7-matheus.bernardino@usp.br> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20181103224948.31014-1-matheus.bernardino@usp.br> References: <20181103224948.31014-1-matheus.bernardino@usp.br> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch adds a channel type check at the beginning of the ad2s90_read_raw function. Since ad2s90 has only one channel, it just checks if the given channel is the expected one and if not, return -EINVAL. Signed-off-by: Matheus Tavares --- drivers/staging/iio/resolver/ad2s90.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/staging/iio/resolver/ad2s90.c b/drivers/staging/iio/resolver/ad2s90.c index 9c168b7410d0..3e257ac46f7a 100644 --- a/drivers/staging/iio/resolver/ad2s90.c +++ b/drivers/staging/iio/resolver/ad2s90.c @@ -34,6 +34,9 @@ static int ad2s90_read_raw(struct iio_dev *indio_dev, int ret; struct ad2s90_state *st = iio_priv(indio_dev); + if (chan->type != IIO_ANGL) + return -EINVAL; + switch (m) { case IIO_CHAN_INFO_SCALE: /* 2 * Pi / 2^12 */ -- 2.18.0