Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9178647pxu; Mon, 28 Dec 2020 08:32:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJyz/o3Xfs76ESKxbGlW3yQz6LpyK2TGCmNzHSD+7fKfuUqRZUK7K52BSBGDhZsO3boLZ+7Y X-Received: by 2002:a05:6402:b88:: with SMTP id cf8mr43913352edb.140.1609173122729; Mon, 28 Dec 2020 08:32:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609173122; cv=none; d=google.com; s=arc-20160816; b=lvKwVpd4c4KnhPCZEUYcD8mSIyAlpbmGXHicNTSVrm9zqX3SED/pfvKLm9JBNX3awF 6cjKN8w9e6XM1mHVWEOV54P+TKR8EddlGnO6Tq25h+qj/vChJHqQaJoa1Hr8Gh8TtxMd YRH/mXOC4Z7eIXlt0yYZTh3i/rmqTQOio7eshaUO87Wr4ABIYU9fp4OuR5XI841DGX+P yqosMjAztfPL9h9P8rSbaPvYDad+GqCFWQD/b+f1t5mxq1pJumzmV2bEsvlBhW9jC9V+ MOmcci80Af2vsYF9KHLL/mR+9+O+lTcglmm+2rbdlSi3qu9QaaELZUcepPcExMHloMlA Cynw== 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=j6EvLzoFniyoxR670iclUWvaOeC85/ZapuKVa/cXP5w=; b=SS6jr7AyiMf+xsZjGC7xMxRp2TK2AbOgAUS5ZkCwBrlr1AErl7Perpt0Jrogv+roh8 7Rb/+RL1CMPTc3DR+t9jrSVRt1MqLjm2ZVJx380AfYqkY6L+CKiNKjT4rsdT0HvmqYeJ idm5qjQfroILrIKnVBHVbqzo8mwEy2fd58xQptb/TsFAfAGEA7iwTaMvgt3IFLfkPW4C Lic1oxdm0/4gFtZ+KPVMX9/dYO3yu8ta0/lXCAJVFqLjNDfEkbTJZKGuyxBPzeWpSwZw 56MshNAAgoiomlL5t6YuXlSErnZkUcMIcugJXJ+XtnWY0pt24wd4ws7/2ktSMLuTKjrI sXMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=yCi+N6lT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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 v4si22968956edi.191.2020.12.28.08.31.40; Mon, 28 Dec 2020 08:32:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-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=yCi+N6lT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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 S2633602AbgL1Q31 (ORCPT + 99 others); Mon, 28 Dec 2020 11:29:27 -0500 Received: from mail.kernel.org ([198.145.29.99]:34940 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730697AbgL1NHM (ORCPT ); Mon, 28 Dec 2020 08:07:12 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6601B206ED; Mon, 28 Dec 2020 13:06:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609160792; bh=U/rmShT16J06mM0R42BKT9PDN+UC8RCxGEEbHBvPTYo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yCi+N6lTd85IRVYYfm1VnMS/kiPEH/tB8D+f1RoE5Qw0o2vu2nbk3Gu4Xw+kIx7e4 hDSP5iVQLa4IYeY+AQIBYMB82KFXalUGKbJmCz2iNNGBWGfyTUUm3Is3+5PGQryi5J v8ETHDwdk9Wrn2Kunk+d2iRQfbuOFnQa3kzjZmtM= 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.9 172/175] iio:pressure:mpl3115: Force alignment of buffer Date: Mon, 28 Dec 2020 13:50:25 +0100 Message-Id: <20201228124901.562817115@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228124853.216621466@linuxfoundation.org> References: <20201228124853.216621466@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 @@ -139,7 +139,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);