From patchwork Mon Jul 12 06:10:22 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: 472973 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp2683385jao; Mon, 12 Jul 2021 00:24:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzAqacvhXo8SjE18RQxnBxUgomVLGSXqf9uiPI7vWy4SQT68x/tj2OCGoPphHbzdz+MGJ2U X-Received: by 2002:a05:6402:268f:: with SMTP id w15mr47433564edd.206.1626074644448; Mon, 12 Jul 2021 00:24:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626074644; cv=none; d=google.com; s=arc-20160816; b=NHuXFlea6GukHogDCLnggzrKsaExw8+ObZbCjeu95uJXJeaRwMkWZlHD2+iqjFzKOn 7YH92D2dNMK4qajb4Xyvj3w842bL0/5Amd6p1mKTYvt8glQ5XR9VYIk+UnC509aWg8PI sJKBLj5W1CNAi5WsRPodz6JQwjOA/ijQchbdkQhzZrwT8IKjU5qcl2rrAqLEQT/k2J1K AJn0XF4BD1cdJG5VmqRC1QrWhbZpkU6QQnNS61xfNh+E4jNfTQ/MGtdKiPqp92Ohx81Q tP9XBfq2OjyROFqrqyVNuplGRJxyqpWzHmMVWMRy/TH8AqyC7cgkOakr6ZZf9G33OXij 35Ew== 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=UaX7Qa1AL24PhHbZCjzZ7BMwq5v+C4S00bWsndkY0E4=; b=nRurUZANH6gQGfU4SxeM44JHEi4sFlVElz1IUMpInYQOPW6Yl2Rg1M/aY1ZUyoBp4H D4smJQchyrkZkGD6WFJ5Wnjw+wb0udjfg1ENhuX4eKN48qJX1aK3rlW0Axs0xVpoLmMG UlbJoGHjtfDsgSFJnolHBxNefXg+fE7OAayjYUyo1LKm4wMfgtM08gaLYsUd7Ql+WxM5 9RiAVmmldTztPerpwzbPO+pTnrssvlr/91zuJjpE2buwS5xL0qschvdIpmJwrhh8Dm1u 9uYgRkSHY1O68/1gweQsWtWQFcGDgj5hE33jxFCSYeH1CKMoJe9UTCM0pJUvy1oQdkOk 1nnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Y3W12sdc; 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.24.04; Mon, 12 Jul 2021 00:24:04 -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=Y3W12sdc; 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 S239939AbhGLH0O (ORCPT + 12 others); Mon, 12 Jul 2021 03:26:14 -0400 Received: from mail.kernel.org ([198.145.29.99]:35156 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243118AbhGLHXe (ORCPT ); Mon, 12 Jul 2021 03:23:34 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id D771961370; Mon, 12 Jul 2021 07:20:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626074444; bh=PGPwFByimew3NOMYXmeazQrzDVNi1cBMz0s3ADpp2Go=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Y3W12sdc720QajEqxlQAEyxSLtAGZ/65RHKSdDibOSVs1G0bRDhVCsR1CbOWVztZO ungREWrhPvCJABNx3mz6V2vf5n0WNq7hZ0nNe4WSxUhDbPvs+OkyHR97zqjE1Ejt5M tQQUkl03shMRkl8Sg3P8FrXsvbPcBlqhDF075b2Y= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jonathan Cameron , Daniel Baluta , Andy Shevchenko , Andy Shevchenko , Sasha Levin Subject: [PATCH 5.12 539/700] iio: adc: ti-ads1015: Fix buffer alignment in iio_push_to_buffers_with_timestamp() Date: Mon, 12 Jul 2021 08:10:22 +0200 Message-Id: <20210712061033.727771916@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 d85d71dd1ab67eaa7351f69fec512d8f09d164e1 ] 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 this function. Fixes: ecc24e72f437 ("iio: adc: Add TI ADS1015 ADC driver support") Signed-off-by: Jonathan Cameron Cc: Daniel Baluta Cc: Andy Shevchenko Reviewed-by: Andy Shevchenko Link: https://lore.kernel.org/r/20210501170121.512209-9-jic23@kernel.org Signed-off-by: Sasha Levin --- drivers/iio/adc/ti-ads1015.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) -- 2.30.2 diff --git a/drivers/iio/adc/ti-ads1015.c b/drivers/iio/adc/ti-ads1015.c index 9fef39bcf997..5b828428be77 100644 --- a/drivers/iio/adc/ti-ads1015.c +++ b/drivers/iio/adc/ti-ads1015.c @@ -395,10 +395,14 @@ static irqreturn_t ads1015_trigger_handler(int irq, void *p) struct iio_poll_func *pf = p; struct iio_dev *indio_dev = pf->indio_dev; struct ads1015_data *data = iio_priv(indio_dev); - s16 buf[8]; /* 1x s16 ADC val + 3x s16 padding + 4x s16 timestamp */ + /* Ensure natural alignment of timestamp */ + struct { + s16 chan; + s64 timestamp __aligned(8); + } scan; int chan, ret, res; - memset(buf, 0, sizeof(buf)); + memset(&scan, 0, sizeof(scan)); mutex_lock(&data->lock); chan = find_first_bit(indio_dev->active_scan_mask, @@ -409,10 +413,10 @@ static irqreturn_t ads1015_trigger_handler(int irq, void *p) goto err; } - buf[0] = res; + scan.chan = res; mutex_unlock(&data->lock); - iio_push_to_buffers_with_timestamp(indio_dev, buf, + iio_push_to_buffers_with_timestamp(indio_dev, &scan, iio_get_time_ns(indio_dev)); err: