From patchwork Mon Jul 19 14:50:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 479879 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp4218095jao; Mon, 19 Jul 2021 08:12:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwC6v2lVEqm9JtrCA7gXFVGR7BHimwkYGDQvG4gt8ldx7uHYssq7DO9LpoKf1eKW+n+E3g3 X-Received: by 2002:a17:906:dc0f:: with SMTP id yy15mr27079991ejb.255.1626707560161; Mon, 19 Jul 2021 08:12:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626707560; cv=none; d=google.com; s=arc-20160816; b=JuADzlHskJLhBLOON5m7q5ItnjZpC78VefQ5Cjusrq1z7qpNOm7O7S8dDu5GLFGhEW cdq2vASdYDX3ky+/1tzcEUif799YwlYafcBrjDX11irvij0++MCjyu8LEMiFoB7rPd6P dbKk4prj1tlliOm5n6USw0qTx7kcB+gzTYbSyiw3a0vOGhJI8udggi7Ji7+sH6lpPtsX ntxlW5bkcYuhigmm5+vhNdCDySwSVG1S7Ye7cRvuVkWSqMdPrXRGLgbLbXrsGQHF7cpE 7Ul1KeDE/gESqtvGLOayzQH3UDdezkca5v8iriDBSGxWq7BcER4FFQXE7IoMjahoGW3c MfpQ== 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=4Fo8UAAmZB+ZNXiapTR/whRDGxoaUDSHLyG4AiRy7zU=; b=TpziOhDukgL7ZbaXTmOsXFHXt3qK0mYiecGXg6YlR0kMBg9aNMR/jQF20hz2rniXeE RWBY2O66P3eCFO6fzMYuG598caJNgO5wtmAi4+hrfHC9hop2pacd+xIA0VWZlL/elNGN ZKJebaWvYReopJn2AQDyGqJQLN1bfofgewNXRW+4kS0hFIhU4Hynf0z6svpbfx/Jy4E3 zLdRoarMRau2C9WLycuSki44zI7CJFr80/6t9BoF13+JpXyavIIJs8ieBud7jzGgYmgD aRnRt70bKYmlFF7AWIBPTM5DuOizZEk/lAd52rYnBwTj6FCUL72EKuY4OQO4VHyO7LJR FPwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=X6y243bh; 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 d26si20449114ejc.620.2021.07.19.08.12.39; Mon, 19 Jul 2021 08:12:40 -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=X6y243bh; 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 S245273AbhGSObh (ORCPT + 12 others); Mon, 19 Jul 2021 10:31:37 -0400 Received: from mail.kernel.org ([198.145.29.99]:39180 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244498AbhGSO3s (ORCPT ); Mon, 19 Jul 2021 10:29:48 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 425E561221; Mon, 19 Jul 2021 15:09:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626707386; bh=ty9UynT7PDHbcdewFsITahOLJKeL+JHzrnPnrkjxVss=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=X6y243bhzQuGA2dtC9zoYBdStGxkm7mcDKewg3smGb1KZQBHRhfll8u/SRrA07RJN hiW6iO1no8AoS1rJLmYX1vyGtN1Ccp43BKwoYtlT6ekB3vWAzKDSA9etZ+sBiAvuON M3UBloFYXi29/b/mxsHxfvWSzltaVMi+drWMDJW4= 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.9 099/245] iio: adc: ti-ads1015: Fix buffer alignment in iio_push_to_buffers_with_timestamp() Date: Mon, 19 Jul 2021 16:50:41 +0200 Message-Id: <20210719144943.625719346@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210719144940.288257948@linuxfoundation.org> References: <20210719144940.288257948@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 5afe32f6587b..d892c0fe5c31 100644 --- a/drivers/iio/adc/ti-ads1015.c +++ b/drivers/iio/adc/ti-ads1015.c @@ -292,10 +292,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, @@ -306,10 +310,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: