From patchwork Mon Jul 12 06:10:58 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: 472867 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp2648610jao; Sun, 11 Jul 2021 23:31:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy8mJZmJIT9URaCLyOyQlsSsUEIqk0aqOdvOnz/dXqnIDuaj4bQ8YlgBSst8HH6ptobSBYy X-Received: by 2002:aa7:c1ca:: with SMTP id d10mr11941461edp.107.1626071462420; Sun, 11 Jul 2021 23:31:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626071462; cv=none; d=google.com; s=arc-20160816; b=L73XIZFDA42mQQ08LyJ0gIYyqFbhf6BJfSUrF4hFbAQR13eEbbRQFoYa17lNXFg3S6 ++ImuMvd/l9Y9kfZRFkAGY9z1g9dMslMr3a1VIrkZttfixC8nDqK+pRTJTAuECv3PD/i TmFjzlhW6DQJR2Dbz8PHA/ktzy/sRCyL0Lv3r/5oSNkjJX3Dji56Nv9auzI9D4t1MzUf B4DEDq18kl//deqL2pvCJJo45Zji04kKjaBlGmNbVSVAsRKZBs7eizFnQDhNBcnh9Z1+ /Ffwv7SfvsUQnMq4MhO2MeYpM76dUS4CqqxHizJZ/qEUqPv/MJkZhLQzpGrYTKhQpvt9 v3ig== 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=NzjJKPoiBV8lTBIUayp0tiIzSJzxzCpJ+CrVZ8/YLRk=; b=ewcT9xljPMd0Tu35F9YU25NhlroLheHfuPib/Y3dJo89Up02Fwe9G8QT53Y+ys/AwL mRs5My4pPVZ2hMHxIe09c0l4gjTdafn8WpIGQiqnjvYNESNJ8BeEj77NKNyPhAl3An7y OEOnodUJiHDOBQED0vIi+zxfiwnITxIhh4D7dXad9GhZCHpXGQDKUxyRcMIc05P6hUBO Nac5Bz9JJ/Bu3oZ0bEc/EyvXy2yymVa4Q68ExJfJR2KHyQ4QpQfaj0k0S1pP69qEXCMf 4qW2iaEUU6BF0xOulRiSeJVvyq52URLXWnDZxmRioEIpaLfZNt9c7GMSsCWj2CUctSpi UQ4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=d3LyN821; 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.02; Sun, 11 Jul 2021 23:31:02 -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=d3LyN821; 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 S236970AbhGLGdl (ORCPT + 12 others); Mon, 12 Jul 2021 02:33:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:48364 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235367AbhGLG2n (ORCPT ); Mon, 12 Jul 2021 02:28:43 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 82103601FC; Mon, 12 Jul 2021 06:24:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626071100; bh=SnMFXj708obsDsyCdyO7TOw96NPoKd3zUkDoQrGOARo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=d3LyN821PAve2jddl8HhbQxMyhaGQ+nWZBQ2ZxBA8p+S6cj7/kI71rLwodCaECnSZ n/h5HWYvqw3jTp9Z2GEBd2Uy92K3/VND9H6NFHHeoeAAKBoKQLCJIAQslbu2daKwbl PV9JZgn/Gb/WR9hUp2nXByt4RoQ3muBr6Bh/dmcw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jonathan Cameron , Matt Ranostay , Andy Shevchenko , Sasha Levin Subject: [PATCH 5.4 274/348] iio: prox: as3935: Fix buffer alignment in iio_push_to_buffers_with_timestamp() Date: Mon, 12 Jul 2021 08:10:58 +0200 Message-Id: <20210712060740.069337802@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 37eb8d8c64f2ecb3a5521ba1cc1fad973adfae41 ] 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 uses of iio_push_to_buffers_with_timestamp() Fixes: 37b1ba2c68cf ("iio: proximity: as3935: fix buffer stack trashing") Signed-off-by: Jonathan Cameron Cc: Matt Ranostay Acked-by: Matt Ranostay Reviewed-by: Andy Shevchenko Link: https://lore.kernel.org/r/20210501170121.512209-15-jic23@kernel.org Signed-off-by: Sasha Levin --- drivers/iio/proximity/as3935.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) -- 2.30.2 diff --git a/drivers/iio/proximity/as3935.c b/drivers/iio/proximity/as3935.c index b591c63bd6c4..718150a93133 100644 --- a/drivers/iio/proximity/as3935.c +++ b/drivers/iio/proximity/as3935.c @@ -61,7 +61,11 @@ struct as3935_state { unsigned long noise_tripped; u32 tune_cap; u32 nflwdth_reg; - u8 buffer[16]; /* 8-bit data + 56-bit padding + 64-bit timestamp */ + /* Ensure timestamp is naturally aligned */ + struct { + u8 chan; + s64 timestamp __aligned(8); + } scan; u8 buf[2] ____cacheline_aligned; }; @@ -227,8 +231,8 @@ static irqreturn_t as3935_trigger_handler(int irq, void *private) if (ret) goto err_read; - st->buffer[0] = val & AS3935_DATA_MASK; - iio_push_to_buffers_with_timestamp(indio_dev, &st->buffer, + st->scan.chan = val & AS3935_DATA_MASK; + iio_push_to_buffers_with_timestamp(indio_dev, &st->scan, iio_get_time_ns(indio_dev)); err_read: iio_trigger_notify_done(indio_dev->trig);