From patchwork Mon Jul 12 06:10:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 472872 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp2648691jao; Sun, 11 Jul 2021 23:31:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxjppGOK0tHKiqBJM/eguGhlYhI82+vEuI2bzRe2Et6QLVgWgaQg8FjeUM5W7ExkxJrodfY X-Received: by 2002:a17:906:660f:: with SMTP id b15mr51560666ejp.443.1626071472140; Sun, 11 Jul 2021 23:31:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626071472; cv=none; d=google.com; s=arc-20160816; b=gQZT8U9pnzSgvbMHce+Mggpj4Bik99NVhAM3SrpRgihSabAYQtjLoWC5nAxHORuOUl 8GJg0lIevzPqkPXQoJQTqF6bEYnJtM+lhIfg7NTY9UG5JzUCUBiR3iGzydZRxEue+R/g MO39XfTcfHHKJGZi6QzNMIxMjRt+X76xp013ExSbmwSQF36WP4bQznqKG6ZywiaPp4vA nVaAEBNvvFuSNUiHtUsvEerUBvvz3K0oX+iqfx0foXbMd+Pufo1fudTUxGNGpiNgBRIs aX5hrh8yReUidHcQ+4NYvEfVoTfKZMwEjSbLQBRDXViEIY4fpKvaycbryAP1EaUM9jvy 3pSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=wWTu48HQ/Icbv4egcYlJJAn86+4eqOniaumTMgyzJvY=; b=PnQXLYEgQAZFkraUE9NVgYrEIS1lWKAIHPz/f2TtmtvSYY8heIbvY+eAOokL4ZYpOb FxlUKxCyptrc4c+sDffuQkZr5q+T6Mb61jgn1/VXvcA/eW1ypSm04PuUd3oppXIdk+4i NcjElvRT0j+9Q7ujJDWZ+QjlwJlwOb0gz5HtP4CoDSAVoh9NFA8uVBEYkBS7TPD5pKrg qXiFaY2Vd2kTmZ8vXCJJSuQqHWtLO1NYfUjivlVPeVYqTDAIgtIi1+MzbAridZeE1LDC /Un21/N7G0tOyyjRVpyzC5m+248GPqygmfGykEtgrRqlI5nkEt8qkhwMld/F9CWiErfD 9blw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=SblR3obm; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b1si16242569edx.272.2021.07.11.23.31.11; Sun, 11 Jul 2021 23:31:12 -0700 (PDT) Received-SPF: pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=SblR3obm; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237096AbhGLGd5 (ORCPT + 12 others); Mon, 12 Jul 2021 02:33:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:48092 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234786AbhGLG2b (ORCPT ); Mon, 12 Jul 2021 02:28:31 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2031061159; Mon, 12 Jul 2021 06:24:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626071083; bh=AzwO4vlk1owGk3CQalajV4Oqq6GjSZ0YTTKw53Td/bA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SblR3obmOjLQ9sLv4O2/DgapeXE4LpIY1WwFdwNr5RL7+HUkzVer0DLM1EhIjMR1H xE3rxCOPCvkvZ93HJvrgbAamhsm2YbeWE7SCS5rMr5Gxflc30Yr2Mofs+wksSkQamF ejfEw4rp6z7YJsZ+ctIG/GpfhaT26ZDnYcqSTz0w= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jonathan Cameron , Daniel Baluta , Andy Shevchenko , Andy Shevchenko , Sasha Levin Subject: [PATCH 5.4 268/348] iio: adc: ti-ads1015: Fix buffer alignment in iio_push_to_buffers_with_timestamp() Date: Mon, 12 Jul 2021 08:10:52 +0200 Message-Id: <20210712060739.110002714@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210712060659.886176320@linuxfoundation.org> References: <20210712060659.886176320@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Jonathan Cameron [ Upstream commit d85d71dd1ab67eaa7351f69fec512d8f09d164e1 ] To make code more readable, use a structure to express the channel layout and ensure the timestamp is 8 byte aligned. Found during an audit of all calls of this function. Fixes: ecc24e72f437 ("iio: adc: Add TI ADS1015 ADC driver support") Signed-off-by: Jonathan Cameron Cc: Daniel Baluta Cc: Andy Shevchenko Reviewed-by: Andy Shevchenko Link: https://lore.kernel.org/r/20210501170121.512209-9-jic23@kernel.org Signed-off-by: Sasha Levin --- drivers/iio/adc/ti-ads1015.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) -- 2.30.2 diff --git a/drivers/iio/adc/ti-ads1015.c b/drivers/iio/adc/ti-ads1015.c index 871690a47661..7929891f568e 100644 --- a/drivers/iio/adc/ti-ads1015.c +++ b/drivers/iio/adc/ti-ads1015.c @@ -388,10 +388,14 @@ static irqreturn_t ads1015_trigger_handler(int irq, void *p) struct iio_poll_func *pf = p; struct iio_dev *indio_dev = pf->indio_dev; struct ads1015_data *data = iio_priv(indio_dev); - s16 buf[8]; /* 1x s16 ADC val + 3x s16 padding + 4x s16 timestamp */ + /* Ensure natural alignment of timestamp */ + struct { + s16 chan; + s64 timestamp __aligned(8); + } scan; int chan, ret, res; - memset(buf, 0, sizeof(buf)); + memset(&scan, 0, sizeof(scan)); mutex_lock(&data->lock); chan = find_first_bit(indio_dev->active_scan_mask, @@ -402,10 +406,10 @@ static irqreturn_t ads1015_trigger_handler(int irq, void *p) goto err; } - buf[0] = res; + scan.chan = res; mutex_unlock(&data->lock); - iio_push_to_buffers_with_timestamp(indio_dev, buf, + iio_push_to_buffers_with_timestamp(indio_dev, &scan, iio_get_time_ns(indio_dev)); err: