From patchwork Mon Dec 28 12:50:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 352734 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp9848296jai; Mon, 28 Dec 2020 07:57:06 -0800 (PST) X-Google-Smtp-Source: ABdhPJwORDi4D6XIgfM2TA/Juqv/StSNlR/Rsc3Mlx64VycYIk7CIv+b7eWkEGVioWhZTsbumcZ+ X-Received: by 2002:a17:907:3f0d:: with SMTP id hq13mr40662450ejc.142.1609171026657; Mon, 28 Dec 2020 07:57:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609171026; cv=none; d=google.com; s=arc-20160816; b=j+NpFPGjyWjlMq5cYw6C1rasy9Xtm64zW/f0hSzMwJ14shHCh2glPtd53Yw7i8z5+A vYle7qxqY9NXzwd1jbRcqTrK2Rndhoz2bW4X7FHrceO0+m1rpr526oO1kYQ7KFBXoT7I wfJ9yYVEdUTbbvEAtN/QSGsDUtO4Fdl9MVVyCkAmou1ljxEsTUP11j8cDhy6E/EPzw7H Iunxk5ajb2xGD3vuUFD8+1KyvY3YrzkBaJtDOE8lQ0ckkFHFv52NiwftsbuEOOnVdP1r 5hy+/ZIwJALP0bGwWgm3f3lVsmL3hT1tjBRep6WRnrADls8ndgqGgTiqS6BxZtRAdh/1 sSMw== 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=9DCwipC9sBkBHpfT8AqJaxaVVPQTtuUTkhDvxTOEIg8=; b=vdtjMcwuUE438mXxcc9Zu53KRWwLulSKqnLvCOpf76COSkBVYhPS6LIGfzZTPI2wXE jKx6wbfZX1G84GoWvGRllaoYDdQL2l6T3gEykj3y28m8mIrEzt1iFURo1QY9W0ERjyG8 yDD5uH9YTP4zfSYQqxOVNVMDceXNynqmVOuetQUVPBNLUwByn5L8+z0oFOsp8nkDliJb d5HiSd2dqNd13Jyznj2QjcnH4EZS5+KoBxZbv1GnLCCIkS3yooCbQo4nZfNRYjgXTuwe act4xUz0JLH1IY2QulR+ARUrkVSnfUE7aakjOHWZjUKNTbwHlBQLX5sX1XAuc6Yqtfa+ TknQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=cF0I+Szb; 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 j26si18774061ejf.716.2020.12.28.07.57.06; Mon, 28 Dec 2020 07:57:06 -0800 (PST) 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=cF0I+Szb; 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 S2389442AbgL1Nfs (ORCPT + 14 others); Mon, 28 Dec 2020 08:35:48 -0500 Received: from mail.kernel.org ([198.145.29.99]:35692 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389434AbgL1Nfr (ORCPT ); Mon, 28 Dec 2020 08:35:47 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6DB4820719; Mon, 28 Dec 2020 13:35:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609162532; bh=2mHN5tE8jCHCqxGUnH47ge8cRXer73I2uY6Qh9H0+8U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cF0I+Szb+eXtYAs9wPYQCFruSwH5tbZmQi9qyv6sPeXB/KX5q3YK0gzF3K+29RptB FZ6SYsugjRcUBLTaKkJ1/+Ur7cToHIRUIEzWSeO9TS5zJyFXx+1KVQRtnOK0ljMIou FT/OSWMjGiRiNOVEnzOlwVtnLC2AfW6xVNXetbh0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lars-Peter Clausen , Jonathan Cameron , Andy Shevchenko , Alexandru Ardelean , Peter Meerwald , Stable@vger.kernel.org Subject: [PATCH 4.19 332/346] iio:pressure:mpl3115: Force alignment of buffer Date: Mon, 28 Dec 2020 13:50:51 +0100 Message-Id: <20201228124935.823925345@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228124919.745526410@linuxfoundation.org> References: <20201228124919.745526410@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 commit 198cf32f0503d2ad60d320b95ef6fb8243db857f upstream. Whilst this is another case of the issue Lars reported with an array of elements of smaller than 8 bytes being passed to iio_push_to_buffers_with_timestamp(), the solution here is a bit different from the other cases and relies on __aligned working on the stack (true since 4.6?) This one is unusual. We have to do an explicit memset() each time as we are reading 3 bytes into a potential 4 byte channel which may sometimes be a 2 byte channel depending on what is enabled. As such, moving the buffer to the heap in the iio_priv structure doesn't save us much. We can't use a nice explicit structure on the stack either as the data channels have different storage sizes and are all separately controlled. Fixes: cc26ad455f57 ("iio: Add Freescale MPL3115A2 pressure / temperature sensor driver") Reported-by: Lars-Peter Clausen Signed-off-by: Jonathan Cameron Reviewed-by: Andy Shevchenko Reviewed-by: Alexandru Ardelean Cc: Peter Meerwald Cc: Link: https://lore.kernel.org/r/20200920112742.170751-7-jic23@kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/iio/pressure/mpl3115.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) --- a/drivers/iio/pressure/mpl3115.c +++ b/drivers/iio/pressure/mpl3115.c @@ -147,7 +147,14 @@ static irqreturn_t mpl3115_trigger_handl struct iio_poll_func *pf = p; struct iio_dev *indio_dev = pf->indio_dev; struct mpl3115_data *data = iio_priv(indio_dev); - u8 buffer[16]; /* 32-bit channel + 16-bit channel + padding + ts */ + /* + * 32-bit channel + 16-bit channel + padding + ts + * Note that it is possible for only one of the first 2 + * channels to be enabled. If that happens, the first element + * of the buffer may be either 16 or 32-bits. As such we cannot + * use a simple structure definition to express this data layout. + */ + u8 buffer[16] __aligned(8); int ret, pos = 0; mutex_lock(&data->lock);