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=-11.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 7758FC433E0 for ; Sat, 23 May 2020 08:42:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 45B4220757 for ; Sat, 23 May 2020 08:42:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590223374; bh=nVrDvs6NwDgNmtOBjHAB4aCc2ZMc7ZXEIL7f6ct2wP0=; h=Subject:To:From:Date:List-ID:From; b=o51ZxB5Ay8eoeo5YC+5hs/FfwEa8QcKM2/Y0pBP766v0Zjkn5muzhLVjZBJiKj0iz 2cSw5U0Ahdf6UvmbPmcNh3kg+AA8t8qtHUIfS6en02Iy5HEY5iXSlZ1OIDUfyHFRDk V8xMcXknA//eQGar449fD+QouhlRVxRhqJBZZI5k= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387686AbgEWImx (ORCPT ); Sat, 23 May 2020 04:42:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:54286 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387666AbgEWImv (ORCPT ); Sat, 23 May 2020 04:42:51 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 844EA207DA; Sat, 23 May 2020 08:42:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590223371; bh=nVrDvs6NwDgNmtOBjHAB4aCc2ZMc7ZXEIL7f6ct2wP0=; h=Subject:To:From:Date:From; b=UQvTsU9bqmSMms3Qv6yVxlP6Rbs2WQUSpAkgsZ7CEspNQwlj2mm/iLPcENIWFWifr EK1/xs4UE9w6QkI8Qb6sa2ss1zvpEAreEoxq/5BQ4VOvqt8LCM6WNBrBh8VmnhJAam pX32Wk+lLHEMBnJDDAC6F3gzyc4s6vxf24jkqVBU= Subject: patch "iio:chemical:sps30: Fix timestamp alignment" added to staging-next To: Jonathan.Cameron@huawei.com, Stable@vger.kernel.org, lars@metafoo.de, tomasz.duszynski@octakon.com From: Date: Sat, 23 May 2020 10:41:39 +0200 Message-ID: <159022329924469@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org This is a note to let you know that I've just added the patch titled iio:chemical:sps30: Fix timestamp alignment to my staging git tree which can be found at git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git in the staging-next branch. The patch will show up in the next release of the linux-next tree (usually sometime within the next 24 hours during the week.) The patch will also be merged in the next major kernel release during the merge window. If you have any questions about this process, please let me know. >From a5bf6fdd19c327bcfd9073a8740fa19ca4525fd4 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sun, 17 May 2020 18:29:59 +0100 Subject: iio:chemical:sps30: Fix timestamp alignment 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: Acked-by: 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