From patchwork Mon Jul 12 06:10:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 473033 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp2713707jao; Mon, 12 Jul 2021 01:10:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw01Gbd5+Wq/GGnVba0n4OpmwqOPn0wmd/HS8DH8bw6YtZFn/GcZphn4q9866EGi3npZER7 X-Received: by 2002:a17:906:8310:: with SMTP id j16mr27813335ejx.79.1626077451048; Mon, 12 Jul 2021 01:10:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626077451; cv=none; d=google.com; s=arc-20160816; b=iaU8sFfMU5IE+nn/oEIGLaurpUFJJuBkLUUFU660JZ7lh4Z4FRa4o8g+Vd1wN8fKA/ unLOwe/z73aRgmeJG+KzscX5DA8hbbcSDRyrrO+SmL+j2eOq5lkHBkwboCAaPlb2uvlQ dr0aZoY/MCF1wKGJ7JtV9iXUuooDupe1MvMnrPlU5AePKVyKb3c9LV5zZhWjx04hcBo2 sciEx8pXSmmGtPtbs/6IXMQhLPuZV5XEoWkkumcTMCDVYn7UtKqp7Vc7Ra6FpQq6q3/s d0d+3mxNhfD+XK8ZqYmsEVfMVltUEqUUzePnWkF5o9Dll+J1mhF1P3i9aMS6Qcl9at98 ztlg== 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=UaX7Qa1AL24PhHbZCjzZ7BMwq5v+C4S00bWsndkY0E4=; b=FZveREqCUUOdNFx1f0SyY8Slm0ixJDSHp5V0pvM6S5wr7uZ+4v0Hav+PClJQA7yhR/ Gw4oCgJ8c0786F4FRMscgA4quWus6wT0lZ73Y8oG+6MsSLdiulWCveG+l1Pf1nTleuWJ gC7GQ7givEgoKF5FvquAlNntm9V84WXZPimhSoC+x9t+ZB4EIhnVpmHX3W2GEIHZzCdC zhCLtlh0dSTPokfEikpjWTiTr2R1UAl+snwsFAC58mstU+pXRACFgAHabtNS4kj7tjrw zOxXnAeow2MQjcI3hVa2KrBXLF0ZC3LXu6FwTwsC+t1XGD8WfH6D7MkWN9wN5Y5tycZM HhFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=YkQtL2Ed; 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 n21si13642925eda.13.2021.07.12.01.10.50; Mon, 12 Jul 2021 01:10:51 -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=YkQtL2Ed; 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 S231365AbhGLIJF (ORCPT + 12 others); Mon, 12 Jul 2021 04:09:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:54124 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245456AbhGLH6o (ORCPT ); Mon, 12 Jul 2021 03:58:44 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 16F856197B; Mon, 12 Jul 2021 07:53:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626076388; bh=PGPwFByimew3NOMYXmeazQrzDVNi1cBMz0s3ADpp2Go=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YkQtL2EdGblwjDR4/jJKqKqOX8cCxu1L/3u5HK8U3DsauxgWPljW43gohOUgb2xhw ltwE/DMt8E2jW0hnkoFwnomgi/NJTYv7egl+8SSgWhoQvXrLCQCngXOg2BmyVicVWh 7ZETcLJASrx8XYlcEwufKethVjLpS0efN4Y4K3OA= 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.13 623/800] iio: adc: ti-ads1015: Fix buffer alignment in iio_push_to_buffers_with_timestamp() Date: Mon, 12 Jul 2021 08:10:46 +0200 Message-Id: <20210712061033.550408128@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210712060912.995381202@linuxfoundation.org> References: <20210712060912.995381202@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 9fef39bcf997..5b828428be77 100644 --- a/drivers/iio/adc/ti-ads1015.c +++ b/drivers/iio/adc/ti-ads1015.c @@ -395,10 +395,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, @@ -409,10 +413,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: