Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3284650pxk; Mon, 21 Sep 2020 09:40:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwA6thbVIP4zM24hYL5Up43bA83E8qN/2kXrAkB7JNPHNhqd15OrBSB14zduR3C+QjC8n/r X-Received: by 2002:a17:906:14d3:: with SMTP id y19mr262795ejc.453.1600706428748; Mon, 21 Sep 2020 09:40:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600706428; cv=none; d=google.com; s=arc-20160816; b=QWqO+5prD+P548mEfsVpt8u89OwY6EndP9gvotw4Hiu53gqqg7q1u+rUsExVeIF/0E 4eoGuImD4HhI1VWdMwGdn6W9r01QDjFb4ztLgZb/8CuBezgn4jyU2YyCbdCAy6c6iTMp oGAebXn6li2lXCVJUKzD16f8zfGzcalH78HDhMdaw2v1wBmR17X873DHsUWwU9iFW5hx +7HuCfsUbhbpkhX2oLYJHmiyNCEO8VpsDuUtVdYFHBEK2jF9JmDSWfNTsCTbeaUam3ht 7rQF/9XiqtXweKf97XuUS0XRIBSrnj/3c8Sqsz/nPxSlTz+qrPceb2q3qcRNQD3IHmzH 8Yvw== 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=NmnIQZdK2ZTtMdcAmmJivMz6m8RyMVyHPpOaDxw2MMo=; b=bD6GRPrxL8HY8FdiTbsmH2s/+bCYDpmYPehk593oXfYGXvGTKw0yF87/5SYyh500LP PCXosOlwtjo42Y/x3MJF76X++lzJ2bw31ODq0xQjHZSUkk+eBQ3P2iAp58ibpDr6MG23 QDAOtYnSBOoaRSsLLMWJuGza4x/8SLUTu+ZCfqgmUmkvjLMYLLiu0n7ya2xn7IxlmtPp PqzAoI3SDCyhWGVJAUST0vnD0FMCK1oJSmhV4f8UaMr/Mq79QcqGDWwl/moe5z3ikuZh x4ncOZFOtG7oTAMx6LzbwZZEI9BPzJZ5qBdlmxgGCU2u/VMnY+W6GJ+UTCD94ekgtEQT s7ag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=jU1zI5iG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (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 k14si8600239ejx.254.2020.09.21.09.40.04; Mon, 21 Sep 2020 09:40:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=@kernel.org header.s=default header.b=jU1zI5iG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729136AbgIUQiI (ORCPT + 99 others); Mon, 21 Sep 2020 12:38:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:38750 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729117AbgIUQhz (ORCPT ); Mon, 21 Sep 2020 12:37:55 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id EE5C5239D2; Mon, 21 Sep 2020 16:37:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600706274; bh=6ttQ1q99cwkgnU2fv5srLVz3lazMI9eFX5Ivf1tdbFo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jU1zI5iGEfjvHNZcRGdrOwQKKkHcPCBfsWdNwLkUtNgsLT7OJEC/eMkpfgtzL0Jfz iGoEuUvLssolZpjLbVM48XI8XcG/SEdwO65ydem+5YNQnkg38I0CEs6w1osy+PSoQP jytjP5zE6xvmXC9iHUYPCoX+PgAftGIPJ6egakU0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lars-Peter Clausen , Jonathan Cameron , Andy Shevchenko , Stable@vger.kernel.org Subject: [PATCH 4.14 35/94] iio: accel: kxsd9: Fix alignment of local buffer. Date: Mon, 21 Sep 2020 18:27:22 +0200 Message-Id: <20200921162037.165444162@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200921162035.541285330@linuxfoundation.org> References: <20200921162035.541285330@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jonathan Cameron commit 95ad67577de4ea08eb8e441394e698aa4addcc0b upstream. iio_push_to_buffers_with_timestamp assumes 8 byte alignment which is not guaranteed by an array of smaller elements. Note that whilst in this particular case the alignment forcing of the ts element is not strictly necessary it acts as good documentation. Doing this where not necessary should cut down on the number of cut and paste introduced errors elsewhere. Fixes: 0427a106a98a ("iio: accel: kxsd9: Add triggered buffer handling") Reported-by: Lars-Peter Clausen Signed-off-by: Jonathan Cameron Reviewed-by: Andy Shevchenko Cc: Signed-off-by: Greg Kroah-Hartman --- drivers/iio/accel/kxsd9.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) --- a/drivers/iio/accel/kxsd9.c +++ b/drivers/iio/accel/kxsd9.c @@ -212,14 +212,20 @@ static irqreturn_t kxsd9_trigger_handler const struct iio_poll_func *pf = p; struct iio_dev *indio_dev = pf->indio_dev; struct kxsd9_state *st = iio_priv(indio_dev); + /* + * Ensure correct positioning and alignment of timestamp. + * No need to zero initialize as all elements written. + */ + struct { + __be16 chan[4]; + s64 ts __aligned(8); + } hw_values; int ret; - /* 4 * 16bit values AND timestamp */ - __be16 hw_values[8]; ret = regmap_bulk_read(st->map, KXSD9_REG_X, - &hw_values, - 8); + hw_values.chan, + sizeof(hw_values.chan)); if (ret) { dev_err(st->dev, "error reading data\n"); @@ -227,7 +233,7 @@ static irqreturn_t kxsd9_trigger_handler } iio_push_to_buffers_with_timestamp(indio_dev, - hw_values, + &hw_values, iio_get_time_ns(indio_dev)); iio_trigger_notify_done(indio_dev->trig);