From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.6 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_2 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 79958C433DF for ; Thu, 21 May 2020 18:43:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4FB22207D3 for ; Thu, 21 May 2020 18:43:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590086591; bh=Q6F90WsqooF9WLNW/pdvZfFVzJhXixN8Qhqoa890kP8=; h=Date:From:To:Cc:Subject:In-Reply-To:References:List-ID:From; b=cX1wenRKLOyXQ3arZnmqzbG7znxGYW/enKErZrlFGsaMWUsBBFgbxxum0qTdPI/oT iOZE6AfR50TOHqv1+jJ6H8yFH5j1KUcj49w76SC/aUoyQpagJjM8aaT0F8ADbIinB+ PbmoBGnlzq/PL1GLgioOlW0VTRAm1cNGbP9TOdwg= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728551AbgEUSnL (ORCPT ); Thu, 21 May 2020 14:43:11 -0400 Received: from mail.kernel.org ([198.145.29.99]:42364 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728240AbgEUSnK (ORCPT ); Thu, 21 May 2020 14:43:10 -0400 Received: from archlinux (cpc149474-cmbg20-2-0-cust94.5-4.cable.virginm.net [82.4.196.95]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 22EE420738; Thu, 21 May 2020 18:43:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590086590; bh=Q6F90WsqooF9WLNW/pdvZfFVzJhXixN8Qhqoa890kP8=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=Rb9z/Pi/6VG5rTW02C+hmKhzHp41CzKHiPCVDKXm0QDntAMcZDOShoL3D4O/ov+UK dLmP/PmULArY6AH0W9/MRRA6ZAxJX824xRerNK5TmmUohExVv3D+WTTJKWQVSYYJ5L B20BDkdBHJwdI1VdYIXigezZs52UIjxaYdHQf99M= Date: Thu, 21 May 2020 19:43:06 +0100 From: Jonathan Cameron To: Tomasz Duszynski Cc: , Jonathan Cameron , Lars-Peter Clausen , Tomasz Duszynski Subject: Re: [PATCH 10/11] iio:chemical:sps30: Fix timestamp alignment Message-ID: <20200521194306.208ea27b@archlinux> In-Reply-To: <20200517190728.GB18033@arch> References: <20200517173000.220819-1-jic23@kernel.org> <20200517173000.220819-11-jic23@kernel.org> <20200517190728.GB18033@arch> X-Mailer: Claws Mail 3.17.5 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org On Sun, 17 May 2020 21:07:28 +0200 Tomasz Duszynski wrote: > On Sun, May 17, 2020 at 06:29:59PM +0100, jic23@kernel.org wrote: > > From: Jonathan Cameron > > > > One of a class of bugs pointed out by Lars in a recent review. > > iio_push_to_buffers_with_timestamp assumes the buffer used is aligned > > to the size of the timestamp (8 bytes). This is not guaranteed in > > this driver which uses an array of smaller elements on the stack. > > > > Fixes: 232e0f6ddeae ("iio: chemical: add support for Sensirion SPS30 sensor") > > Reported-by: Lars-Peter Clausen > > Signed-off-by: Jonathan Cameron > > Cc: Tomasz Duszynski > > --- > > drivers/iio/chemical/sps30.c | 9 ++++++--- > > 1 file changed, 6 insertions(+), 3 deletions(-) > > > > diff --git a/drivers/iio/chemical/sps30.c b/drivers/iio/chemical/sps30.c > > index acb9f8ecbb3d..a88c1fb875a0 100644 > > --- a/drivers/iio/chemical/sps30.c > > +++ b/drivers/iio/chemical/sps30.c > > @@ -230,15 +230,18 @@ static irqreturn_t sps30_trigger_handler(int irq, void *p) > > struct iio_dev *indio_dev = pf->indio_dev; > > struct sps30_state *state = iio_priv(indio_dev); > > int ret; > > - s32 data[4 + 2]; /* PM1, PM2P5, PM4, PM10, timestamp */ > > + struct { > > + s32 data[4]; /* PM1, PM2P5, PM4, PM10 */ > > + s64 ts; > > + } scan; > > > > mutex_lock(&state->lock); > > - ret = sps30_do_meas(state, data, 4); > > + ret = sps30_do_meas(state, scan.data, ARRAY_SIZE(scan.data)); > > mutex_unlock(&state->lock); > > if (ret) > > goto err; > > > > - iio_push_to_buffers_with_timestamp(indio_dev, data, > > + iio_push_to_buffers_with_timestamp(indio_dev, &scan, > > iio_get_time_ns(indio_dev)); > > err: > > iio_trigger_notify_done(indio_dev->trig); > > -- > > 2.26.2 > > > > Thanks for the fix. > Acked-by: Tomasz Duszynski Applied to the fixes-togreg branch of iio.git. I'm going to pick these up as and when I get reviews for them rather than waiting for the whole series to have suitable reviews. They are a small part of all the instances we have of this issue so no point in waiting. Thanks, Jonathan