From patchwork Mon Jul 12 06:10:33 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: 472983 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp2683977jao; Mon, 12 Jul 2021 00:24:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxzjT/rx/I2tTwpcpTY8+PHQNJgVCsgVX1wt8PkP5gtyYgg7hzZJO/u23+Lg//zjxu5kVSM X-Received: by 2002:a17:907:3e1f:: with SMTP id hp31mr2861344ejc.55.1626074597306; Mon, 12 Jul 2021 00:23:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626074597; cv=none; d=google.com; s=arc-20160816; b=K7TGgtTyNLC+rF/OaLaBSV/jGn7OBIZNTMxfoynoPK9xUa4MCswKsp/ZvvSrcw6ol1 9+dZgYKZPVDjnuSDi3I7rdN9zS7SDoexhI6QrtESF3nrv8X3WFnHpXODIekAsBMFmqTU CbmDP2avrAiCFFdA4X5y74mYF5oaTPXeU1F0NgwFwvGZ87p1jeBolN957TOJ6xMg4/uc o91WVwVTBLsdHLJ4mgxTSggrAj7Jv4edXKwRiIIHtzRd0GbudRDzYsiW4oa8vkVM4oLa pbM/PsbeC1u2lMJ0AA5npfoxW82jsw1DFR5i+EFBnydzVTytZzFdTXU89Q+xca3qLHdS dQ/A== 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=D7xOc54EoJlCDqt1Y2nkZGRDLiWySzLVxk5qfzvI3hl0wjF8XCp/MBdbmnEUXICprX OPeMAi0mV63ZsaGu1jdHEDGkwbPMTVTkxsgmGaTUsDS8EQPiSCcGVOWfzlxejUVP5YZ+ shsQPJPnKduXyqvCwc9j32Qm3soNLxMdoZt0Nvww3sWl3oldFuXPAKu2LZi0cW5XlGzS xfq/Dj1sfta3z/1Sm7/PMOS2VSiXC+VUwrrw8ThVjrjv6tOv/PNbN5k60/25REpNR7qx uBLfIAqOUm31UhEtgnFEcah5Vq7k6I+GxBeBj+HsWf11D82KH0+C8FblM716ug6nCr5B C4Ug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=QS5BLVPB; 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.17; Mon, 12 Jul 2021 00:23:17 -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=QS5BLVPB; 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 S240098AbhGLHXa (ORCPT + 12 others); Mon, 12 Jul 2021 03:23:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:60126 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241841AbhGLHVy (ORCPT ); Mon, 12 Jul 2021 03:21:54 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 914766145A; Mon, 12 Jul 2021 07:19:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626074346; bh=4v+nseQdWKDdrAUHjCL5B0ijZTrXt6zOPA7+ThEi7D4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QS5BLVPBROgToewzc7hbOwRgjyf+SmHEcV24rOTFd49Y633xeTFfMb+NTRLwk+B97 Jdf6mYENxbXCUCl8XrFqyi8K2KF/ouumthRDmlf6gjPqyYb+W3sPQ6iV33HX+p0thM 7D+EmIfkwmgjPP5pb420kewZ/PSJEglgsoLxSMLc= 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.12 550/700] iio: light: tcs3472: Fix buffer alignment in iio_push_to_buffers_with_timestamp() Date: Mon, 12 Jul 2021 08:10:33 +0200 Message-Id: <20210712061034.811835717@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 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(-) -- 2.30.2 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: