Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp2714557pxv; Sun, 11 Jul 2021 23:35:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyL9kZ0nJZuI8WUWHWkrSST2Nh9GIdgQMuqq5GmKOwU00a9xPRBX+BR4F/RSNnZR4nVCBcl X-Received: by 2002:a05:6402:2317:: with SMTP id l23mr63803370eda.265.1626071732397; Sun, 11 Jul 2021 23:35:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626071732; cv=none; d=google.com; s=arc-20160816; b=jaL13p4z4gsNyGBLIqyyFKVn5aMNU4FcdWnZ8ZpTCnq0DqilJW/1bGPgEgHxo/2WbN T/6BohiZsJHacXyHc3QR31KUUq/wraeuCeXioHi9hB6hAjflSWMeqN3/g5rthyA9p/PW ASsrQOLfsq/2VE4oo0Ig5Dt38PEEFoxyVTkr2JiuIDjtKXt2NMwrgstYzN0NDslhR0Cx 550Nr/JCIYnmrdHDwD64JCqK6pSsxKF8YdEh0VYaWzuafJNDa10hdSbogvkWQ1myOxdy 7fm+vkTxZV6DU5npysRqxh4rnJCKUZfEaiSRL6YzxF7nLwvm+V4Kvcslk+xEuYoSzxX8 eLHA== 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=KWo0yPWYBsE0dd2Fg+WVZnCUyUqyXGgprAoJGk3rHww=; b=m7OhkIa19TH5PFZy6kWEt6HSVdiVMJ+lOtmyiSOyzXXH0+j+vNYx2K6pTDRrpaFRJE LxjgePw5fD1mnKKl7LjODNIc5zdZRGDhRRMpJN0YThj96P+koYBk/MitnZWQX6Zf0NHd I9lRT6RLq8jN0Herbh4eeZ4PtdhuhbUVfWezikdn5oGiu1kg2UiFi0o6ed8WHikC4l7h KLp5enAy84IyJKVn4s96IHQyODgsQ5b0dJgF9/z8uecB9ePKdq9hNMjoC/WDq+dShqAB RfuiHVlYnM6TnZD4x/0vUhChoxX22JxVL4gYEXH59VcMOp8ZA5p12ZWVa6LA7GySCeBW 6Fsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=NlppsT4P; 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 hd12si15811635ejc.121.2021.07.11.23.35.09; Sun, 11 Jul 2021 23:35:32 -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=NlppsT4P; 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 S237905AbhGLGe6 (ORCPT + 99 others); Mon, 12 Jul 2021 02:34:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:45380 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235321AbhGLG2z (ORCPT ); Mon, 12 Jul 2021 02:28:55 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9D73961185; Mon, 12 Jul 2021 06:25:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626071112; bh=Q+2LZT1Bcn55z2F0p8tlrUYi85vixn6XUe+WHNy1wws=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NlppsT4PtqD9UauOnJWRRLTeqhEytQ4ZmfMuzbU+fPgYLosRlQu6ixvOlGzTdp5Hw DVLNrd39g4EqflUjv7MoM7MKlvoGoJrXtccYITWd+5VbYc5VVF0abgnX5wyIYhi/za zKroHxKz27yMVyOvNaXSuIlh6lusPhrNRMg+GRPY= 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.4 279/348] iio: light: tcs3472: Fix buffer alignment in iio_push_to_buffers_with_timestamp() Date: Mon, 12 Jul 2021 08:11:03 +0200 Message-Id: <20210712060740.679100501@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 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 a30ad151653f..9ea543c5cf5e 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