From patchwork Mon Jul 12 06:10:28 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: 472965 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp2682787jao; Mon, 12 Jul 2021 00:23:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwAb9IZvX8Xn5g9biuyIjN0sxIQ24XwY3L3uZnRQKPGd21vEkUnlTdX6jSsWwi9P/qDfZpr X-Received: by 2002:a17:906:9745:: with SMTP id o5mr51764893ejy.344.1626074595587; Mon, 12 Jul 2021 00:23:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626074595; cv=none; d=google.com; s=arc-20160816; b=g8Wa83tY2GPgvY55CmQKURYPs4VFfoEomUXTdqm53I8XiPDQHUiLJOC54/b6Jip4J8 V/K1Sc007pPTVjk9OZB2ZxJG5EgAySLg9k4LL/qaVzHOWWsqSGuxIQzIR4Oej7vRcK9J 1tObbHQXV7TT6j6x17yUdjbHeV73AtlUVc899JYETjmI026xQL8TgXGBAux0UMYiG0uF oaS0pL0FZwycrwBmDCkMCMA3ZvmnT9FFlW4uSLLmc+mSPhUZbxdV0gc2aU8yvzjOubsk 3D8LW0rdKp3Q4jSTP4aLdyxZ/G4ommM0l1gq+usoeavoNweYRTf+Fq8vYzDT4NXkR8wk LJCg== 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=eEZJbmxRo8/UDLxJQ3+zQmYtd6juE3BTlUZKFI9sVMo=; b=T0D19SC6vnkW6DMohmRYC2cArfmkPh1nlaxo06VedMtLFMdXFJn7nWle19Fz6HgOox qOC/195URMqoOhm1uobjZKMB2CW6QB+O1IXbZLQQLgx0bvXVYvABfkIKjJu/uP5hMpll Xt8d7caHsCdNfpA9zrgubz27MT2cWhHDGHdFMKeMIw8tPb3g+RWi0AYVmgS+FyJa//KX IT0QmpQFLAoB01djPJ7wDVhBk4Ao+nerRBwQdJ6DJhei2/0vV/7v8kDc9Qz/j/dqiSvg /UFENLzxlrSSiOkNZFv8lJCCfvb+U6veRDEHGYSOF9/PqZwGBzxuG2u5oMSZWQK3RjRV ZYOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=bMly7Guo; 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 d9si16909677edq.169.2021.07.12.00.23.15; Mon, 12 Jul 2021 00:23:15 -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=bMly7Guo; 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 S242683AbhGLHX0 (ORCPT + 12 others); Mon, 12 Jul 2021 03:23:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:59618 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344930AbhGLHVk (ORCPT ); Mon, 12 Jul 2021 03:21:40 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0CFEF61153; Mon, 12 Jul 2021 07:18:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626074331; bh=mwf9hJLWPNOdLFUEIsrdC1GGvFET8eaxuSIu33tcvkM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bMly7Guo+CcQX/fsFsSmu282rOxULTq5Bwu5GnlvblvAH7MgH0Lxq6C8HP5HbxI50 B2oZe/O8xL7wJMUJs66+YGdZGAvrGfwryk5gigNznoW7vnHSpaj/oRF62/K03bT7W7 aTr7IthC/ojRoja+SSg6jMbUVtLZOptf4rjL2AaM= 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.12 545/700] iio: prox: as3935: Fix buffer alignment in iio_push_to_buffers_with_timestamp() Date: Mon, 12 Jul 2021 08:10:28 +0200 Message-Id: <20210712061034.323154380@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210712060924.797321836@linuxfoundation.org> References: <20210712060924.797321836@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 b79ada839e01..98330e26ac3b 100644 --- a/drivers/iio/proximity/as3935.c +++ b/drivers/iio/proximity/as3935.c @@ -59,7 +59,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; }; @@ -225,8 +229,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);