From patchwork Mon Jul 19 14:49:45 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: 479938 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp4241018jao; Mon, 19 Jul 2021 08:38:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwvVCU7po6SzLMeaJHz6J2YU0jcHElJw3nDSOAFkll9YrIt0UYrbfgh/7xYaUjCd4SGdTQ5 X-Received: by 2002:a92:7f03:: with SMTP id a3mr4543839ild.254.1626709138920; Mon, 19 Jul 2021 08:38:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626709138; cv=none; d=google.com; s=arc-20160816; b=x/WnxDalmAmZmfZRHU2SZJn0bvkm06E8FxIrDyxgnDZXuUZnq5RGnZB+w8b9sVqEYi K87cSe4RKtwvp4U4ZZOPmq/vpYrvhoXs7U6VBhaIGsn1PMHhG9VHSH2fg+XCwogyLBDv IhFMuhMa++WNIpYPT6m4dxnedTzsQXZf1CrQv/ZicHaVGOE82R0YWTVbdVmoq0+sexdZ ndS3AqSYew7wEk8pKnKra2inUgeBzz2p9r5Qsc98OmnkJuzY23k95IGSTlci/ubuu2Uc owbHepzybh+LrWYwmMFJTrz77nrgacdVAQ7fQ4be08s2wsiSdgufknbslCvGoKqaDAdN KmdQ== 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=7AuDRfaNiihpDmaYQ7ALOQzBbe7bFHjeI1OEJWec7xw=; b=XK/mSHZMEufp3bzP7oU4IpuqVfJkDIqaMggNYkcXLm0g7x+VZ5a+IBvJqg1yNA4LFj DIiBoYYboeOy5k/w5MtdWYhC5LEGX+9Mc7QtsrMUIe4p8qLI62x6LfQXzDDiUj1KTcyz EJRXvM0AGOOtVdxul56lLl/BbjI+Sntmhhl+Hdl0KkrUM67uIAfP4dWB4l5VS3vmV6LJ a1Nj9V5Ax88phDIDBCSRD1DH5DW7jfQrCtc4LLlJ1AWkLlbKY8IhvqI9TZh8QjStDFox /dvDNIwmusshaHOMgIIQKCUXjcOo4+cYnAPp4hPtav+3qOPD+WQgc3nU7d2VQTNwn/LB 4D+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=lBLpsSTb; 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 s9si26098276iow.87.2021.07.19.08.38.58; Mon, 19 Jul 2021 08:38:58 -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=lBLpsSTb; 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 S245349AbhGSO6R (ORCPT + 12 others); Mon, 19 Jul 2021 10:58:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:53810 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244801AbhGSO5Y (ORCPT ); Mon, 19 Jul 2021 10:57:24 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B3855613D2; Mon, 19 Jul 2021 15:35:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626708902; bh=SYAHmLnYfFi8Sjue7Zq7NtIceETwmVttyjLJP76VGQs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lBLpsSTbEJGN2spQ9z1SNfGxyuQ/ELUsRjme6nOLnQFJGC20Sl6me2bFVw81UDpO9 gokqTmnvnunaAr/th+nRWXq3JD0HaJew2vZ28/dMgEZntbMj0vGd8JAhfgdPmIq1QW /ee8pLxTd+pSWhdCFk1wxKTBc/i5LIZpe63cnEmQ= 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 4.19 174/421] iio: adc: ti-ads1015: Fix buffer alignment in iio_push_to_buffers_with_timestamp() Date: Mon, 19 Jul 2021 16:49:45 +0200 Message-Id: <20210719144952.462559698@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210719144946.310399455@linuxfoundation.org> References: <20210719144946.310399455@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 dc8d859e4b92..b1cccc3eeea6 100644 --- a/drivers/iio/adc/ti-ads1015.c +++ b/drivers/iio/adc/ti-ads1015.c @@ -391,10 +391,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, @@ -405,10 +409,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: