From patchwork Tue Jun 9 17:45:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 187695 Delivered-To: patch@linaro.org Received: by 2002:a92:cf06:0:0:0:0:0 with SMTP id c6csp770175ilo; Tue, 9 Jun 2020 11:04:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyTLMRh0Ci4JByR16yIqcFgYTDAgvyqKAOCQ73K+ahmm987eYZYT12xCnIwnZ0m9EyLZ0Q0 X-Received: by 2002:a50:c359:: with SMTP id q25mr28997146edb.123.1591725843721; Tue, 09 Jun 2020 11:04:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591725843; cv=none; d=google.com; s=arc-20160816; b=om6IQwimoQGySDIFP/mrBEYI8UKmtacmwcl/pcCN20Vx3IpNH2BKh8eJRdE8j/eEx/ 9kuniZi+Bs0ZVLhtc37PULwiti2FNF8EsFOurvnYKxcz4jMAtnplTnp1qIltL5Q7VHE7 n0qNHIUmDTzyTgFGePMaWxf7+12c3Mqyodwys6Unl01mI669dP2ADwZUwcSlJqR3P+Xg aEQL7CmxdFTOl5Vr1IoqQv98ekEb76IuampfA9E6NAEOivjO6GcVBcM5UOUR5p2W6ijO FVYN4YcP4vQEHRL7UqLnf2wc8nXDNxhVYlzG+FuyoZxV+g/XvKVxN2pwPU7AZUrVb69N zkWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=bY+5RgWAuj4+Fukc/KBqnT65+4+MKFT1kIjxWaD0A6Q=; b=Aq9bPd10BGzJ3Dc4kOMXO95/esFEq/ZJlVPZ+HSlGqzfjViagNbCl6hz3yc21KLYFK MvFEXG2qjkaFZXOL9hnn4GmN2puHv+EZ6ycWpQ92lUSWQNM9oG0byJWjkYBJaFpM9vn0 z2YDmgZkzIvRRDK5w2l96WAt5OjidAVuQgGDElOJaWJxbOgVHkk8dY7oK6ed5rgAYzqN bf9GdPRd4AMipEXP9RzBEnjCItfY4EDpvwSaActqTNu2IsR3xkhvanlccG3wgvEkmNaf fKz2y03hjqsXTbzyxkRQNmzB2q+nTA3/ul/oCC0FqlsBJM3KxauvA/cqoGNWZ4QOz1i/ /9Kw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="RN/rp31x"; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n25si11282764ejs.551.2020.06.09.11.04.02; Tue, 09 Jun 2020 11:04:03 -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=@kernel.org header.s=default header.b="RN/rp31x"; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387940AbgFISDk (ORCPT + 15 others); Tue, 9 Jun 2020 14:03:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:42986 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732916AbgFIRwg (ORCPT ); Tue, 9 Jun 2020 13:52:36 -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 E6AAE20774; Tue, 9 Jun 2020 17:52:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591725156; bh=9QiSaFPCF+LjbweQTWvY4JtLf48Yd8AZc7D1koPx13M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RN/rp31xaKPWGocFgq6R+seM943Ke/wJhAX2XEsnjJSKLP+oLWrEZuXFFu5o3+MLh JDMQt3PeX4TPrvcbfQ6HMV7AmxxC8ENtEF+GUoWJ2H9kfrragxBmkqXJpo9lbMo4CM e+Brn6Zpi1p6qMAuLuvbrZjsZv0QTOO/eUS/YNHw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lars-Peter Clausen , Jonathan Cameron , Stable@vger.kernel.org, Tomasz Duszynski Subject: [PATCH 5.4 16/34] iio:chemical:sps30: Fix timestamp alignment Date: Tue, 9 Jun 2020 19:45:12 +0200 Message-Id: <20200609174054.670448439@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200609174052.628006868@linuxfoundation.org> References: <20200609174052.628006868@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Jonathan Cameron commit a5bf6fdd19c327bcfd9073a8740fa19ca4525fd4 upstream. 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 Signed-off-by: Greg Kroah-Hartman --- drivers/iio/chemical/sps30.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) --- a/drivers/iio/chemical/sps30.c +++ b/drivers/iio/chemical/sps30.c @@ -230,15 +230,18 @@ static irqreturn_t sps30_trigger_handler 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);