Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp244725yba; Mon, 1 Apr 2019 05:43:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqyMCHI+5idL1ieFCB8G/AsIIKNlVhyIWXarDGQXL9quOvjq8EDuEfZpNteRiUPhgdLUghJg X-Received: by 2002:a62:14c3:: with SMTP id 186mr62378931pfu.21.1554122594703; Mon, 01 Apr 2019 05:43:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554122594; cv=none; d=google.com; s=arc-20160816; b=ov7H+nCEyI9eCsZdEO5ZSTwBKmwdgc3WHWw/uqFBKzEs1jjgl/erJPUDODN5lK/ER7 MydeqhxtSmK/9ADRSj3cy6OYS3EF0aA3FWuWbSQUl3OVaST9zqwIqyV2TjNgnM4VzgPZ Fj3XcFMiotPTwECpY0kv1sPK85CcLHclmhmUlsX/vkOdxiOxZ/P+s/hjxPpar4+u8aoE gzNQesmi+r+Si7msneKnrIfInNiYbSYOFLsgSrd7MsMueLYnP0IpCmsTE0d9c9zyAWVW QvNqy5+0M8/pvRh5JcxYCShVH0LU6JMwbfHOXYPagPEr+xZ/rw7D0P1LrhmIn8lyVfaJ 9sFg== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=XqPg5t8n2NI2G3877JsWJNa5hR67kuHSjala70lVDKs=; b=GxlzdeKZ9r+NYsQdm9fxBAOr9FkXll0RmLZBY4grZI+Bq68d0n3CrVOedP94HgvZV/ Z1VG3HU8x8iAF4r2EWsiwo90h7++Kt2Kc/3gFSFZL2tTVjzWzqCiI93dXMANpVwQuE20 IiUW6Bf89dH9kA/QQGEWIerRdL5/7eaUFO0VBW3TWC2R2MGBaOGVEhyg0E1mZ3hoXrH9 5gcXvhFNVaGYm3j349xLSgTZlp8eyFfNUhp5ywDHEgAAr/yWL7MHVVcIbwbASGUVq7SO H0bIfNBEUqSr5mnxi8yBJm5Z/RlAUG2AKq5G9uzjOYvjP+pBa5LhzXqSh/320+z5qATf I85Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=wZzyKFsh; 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=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o11si8644707pgv.13.2019.04.01.05.42.59; Mon, 01 Apr 2019 05:43:14 -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=@ti.com header.s=ti-com-17Q1 header.b=wZzyKFsh; 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=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726657AbfDAMmP (ORCPT + 99 others); Mon, 1 Apr 2019 08:42:15 -0400 Received: from lelv0143.ext.ti.com ([198.47.23.248]:52202 "EHLO lelv0143.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725897AbfDAMmO (ORCPT ); Mon, 1 Apr 2019 08:42:14 -0400 Received: from fllv0035.itg.ti.com ([10.64.41.0]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id x31CfeIn051164; Mon, 1 Apr 2019 07:41:40 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1554122500; bh=XqPg5t8n2NI2G3877JsWJNa5hR67kuHSjala70lVDKs=; h=Subject:To:CC:References:From:Date:In-Reply-To; b=wZzyKFshdkHR1o9cP7n0PQcbOHac+hMW6ghpZpLQPCc+mWEmwqZe88cezOAjvuXbV NwGnYrHAr8Oc8TJV5nO1w2CSoBxdt6sXfgyuVeU1aeKoeC5VJVQuFO1MLFlSQIwZbC RTxhkhge9eUXAZmF21Whjtqrwcgb7aSWJiyy2jpw= Received: from DFLE109.ent.ti.com (dfle109.ent.ti.com [10.64.6.30]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x31CfdYu046447 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 1 Apr 2019 07:41:39 -0500 Received: from DFLE111.ent.ti.com (10.64.6.32) by DFLE109.ent.ti.com (10.64.6.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Mon, 1 Apr 2019 07:41:39 -0500 Received: from fllv0040.itg.ti.com (10.64.41.20) by DFLE111.ent.ti.com (10.64.6.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5 via Frontend Transport; Mon, 1 Apr 2019 07:41:39 -0500 Received: from [172.22.75.122] (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id x31CfdvF058154; Mon, 1 Apr 2019 07:41:39 -0500 Subject: Re: [PATCH] iio: adc: ads124: avoid buffer overflow To: =?UTF-8?Q?Vincent_Stehl=c3=a9?= , CC: , Jonathan Cameron References: <20190331185423.11749-1-vincent.stehle@laposte.net> From: Dan Murphy Message-ID: <95d93ae2-1b7b-76fc-f72b-014a006f4c21@ti.com> Date: Mon, 1 Apr 2019 07:41:37 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <20190331185423.11749-1-vincent.stehle@laposte.net> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 8bit X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 3/31/19 1:54 PM, Vincent Stehlé wrote: > When initializing the priv->data array starting from index 1, there is one > less element to consider than when initializing the full array. > > Fixes: e717f8c6dfec8f76 ("iio: adc: Add the TI ads124s08 ADC code") > Signed-off-by: Vincent Stehlé > Cc: Dan Murphy > Cc: Jonathan Cameron > --- > drivers/iio/adc/ti-ads124s08.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/iio/adc/ti-ads124s08.c b/drivers/iio/adc/ti-ads124s08.c > index 53f17e4f2f230..552c2be8d87ad 100644 > --- a/drivers/iio/adc/ti-ads124s08.c > +++ b/drivers/iio/adc/ti-ads124s08.c > @@ -202,7 +202,7 @@ static int ads124s_read(struct iio_dev *indio_dev, unsigned int chan) > }; > > priv->data[0] = ADS124S08_CMD_RDATA; > - memset(&priv->data[1], ADS124S08_CMD_NOP, sizeof(priv->data)); > + memset(&priv->data[1], ADS124S08_CMD_NOP, sizeof(priv->data) - 1); > > ret = spi_sync_transfer(priv->spi, t, ARRAY_SIZE(t)); > if (ret < 0) > Reviewed-by: Dan Murphy -- ------------------ Dan Murphy