Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp2738209pxv; Mon, 12 Jul 2021 00:19:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyD/Jz0hnkxSRHM5Hapx42d9mcbzY0ij/9pgrphzU/YtIHPz6xw9873oyoHjLpActcgaVAM X-Received: by 2002:a92:2e08:: with SMTP id v8mr34380303ile.50.1626074388895; Mon, 12 Jul 2021 00:19:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626074388; cv=none; d=google.com; s=arc-20160816; b=nN66IDpSCMztnbH8mCuSMEkLC3NNHFxzU/GsfviPXdqiW8F0JSVM0bQ61q7mPwj+RR oOSjZm7XtvpA9ZFO027O6cm6X9cr+QK5/geVUiQVLSQN3SMlMh0cb7KEXGi8sMsDR8h5 RLH6Ff7iCxI7HhioeHPtEvxb0DZ5NqiHgO/RQpJb94wgROv4bQTz30q5QU8Bq8LEQXns QxJGn07xkRGixCHZYISjFUy+itBMYYvIB07EeMzKuOgPHC91fAfiNBqZNdU2EDi0KEGS pTU7TDkmLyTjq8tEZf8ToK9s+LXZNyFbBlulA8487XCaY1eS503YCToqu2a2OHMUfYpu rzfg== 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=BrgWfoBNUAmO4ugJ2rfvyhn/OOkcpsWRIA0Xl8/Gb7k=; b=rHxNKygCoTXHPGYSlipi4To+IEC/913P2M3jIpVCY5E4WTgv6M/pRIJfwifny5WNun i83dSIxNpjggKLz0tmEvPosvLA2C/L6Bza4d+1DliUoc7+dROFfPEEcPgshjIVVOBeyO jHNcynF99NjfykKI3b0MxMuVK8DNCFsrfPsHN8ZTUD+/GxZx2hPn/YQnZHAHy8SIr2+y WE5c1xoaFRkoa4CXnIfyKC72lEo54Zij0bDRguOXSiPnQoQKiisP1fpYpg0AwJbRNLxT EZ8Uv9yhCZNma4jKE2KMu8G7pBUq66dEsdKDEE2R2BOqO4Kr6sU17m7bafGUpi5J8SQh BbFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=lDnhD8ks; 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=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 r9si19272726ill.121.2021.07.12.00.19.37; Mon, 12 Jul 2021 00:19:48 -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=@linuxfoundation.org header.s=korg header.b=lDnhD8ks; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344594AbhGLHUl (ORCPT + 99 others); Mon, 12 Jul 2021 03:20:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:48264 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239061AbhGLGt2 (ORCPT ); Mon, 12 Jul 2021 02:49:28 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 83F2A61183; Mon, 12 Jul 2021 06:45:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626072359; bh=4v+nseQdWKDdrAUHjCL5B0ijZTrXt6zOPA7+ThEi7D4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lDnhD8ksyuDLQ6g72L/BGC11lN8YWkt4uO0AqQ0VLbicumiMtbaPHYxtqoLrJVF43 WNOtltguqB4iIZ7s4YyTTo4k7v5Y/5U2l02Y2hGxQpbh390f5sVVEuFGgbSqeKi6cT DAzrerWa3l5aRwKs2KDjcy/13QRblAzcA69LTqMg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jonathan Cameron , Andy Shevchenko , Sasha Levin Subject: [PATCH 5.10 463/593] iio: light: tcs3472: Fix buffer alignment in iio_push_to_buffers_with_timestamp() Date: Mon, 12 Jul 2021 08:10:23 +0200 Message-Id: <20210712060940.599173194@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210712060843.180606720@linuxfoundation.org> References: <20210712060843.180606720@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 [ Upstream commit df2f37cffd6ed486d613e7ee22aadc8e49ae2dd3 ] 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 tag is not strictly accurate as prior to that patch there was potentially an unaligned write. However, any backport past there will need to be done manually. Fixes: 0624bf847dd0 ("iio:tcs3472: Use iio_push_to_buffers_with_timestamp()") Signed-off-by: Jonathan Cameron Reviewed-by: Andy Shevchenko Link: https://lore.kernel.org/r/20210501170121.512209-20-jic23@kernel.org Signed-off-by: Sasha Levin --- drivers/iio/light/tcs3472.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/iio/light/tcs3472.c b/drivers/iio/light/tcs3472.c index b41068492338..371c6a39a165 100644 --- a/drivers/iio/light/tcs3472.c +++ b/drivers/iio/light/tcs3472.c @@ -64,7 +64,11 @@ struct tcs3472_data { u8 control; u8 atime; u8 apers; - u16 buffer[8]; /* 4 16-bit channels + 64-bit timestamp */ + /* Ensure timestamp is naturally aligned */ + struct { + u16 chans[4]; + s64 timestamp __aligned(8); + } scan; }; static const struct iio_event_spec tcs3472_events[] = { @@ -386,10 +390,10 @@ static irqreturn_t tcs3472_trigger_handler(int irq, void *p) if (ret < 0) goto done; - data->buffer[j++] = ret; + data->scan.chans[j++] = ret; } - iio_push_to_buffers_with_timestamp(indio_dev, data->buffer, + iio_push_to_buffers_with_timestamp(indio_dev, &data->scan, iio_get_time_ns(indio_dev)); done: -- 2.30.2