Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9101723pxu; Mon, 28 Dec 2020 06:40:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJwrfccUJ8TuBOCavFi3q10tdfRWdTd9ljk+vP9r3jvD+DtB1H3w6P8bLKfC+AHgXz0yuSlB X-Received: by 2002:a17:906:7146:: with SMTP id z6mr41552889ejj.379.1609166455908; Mon, 28 Dec 2020 06:40:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609166455; cv=none; d=google.com; s=arc-20160816; b=Rt/jKci4kyCQL4erszkgnuFnF/+QAvW1e5d6ZJGWXsyo2FiRIXwYSU6Hf5eTQ/fyca cuwz9B4dpJLUbO5Ui0zxdcaPHDrLF2XJ2ew5QzwgAqnrxUdgVWnATJLOqHWyrlEt4L3B taiDfwRLG0R+GVOguqCBoyfsmaOMMqOjkfG+Q2A6OGY5wSyWkshKA5Pa5MOcsn6r8xYg KuGo3r8uGAf2Ics9vIoHjEaJZFPym3rgTRngIWZIKvTfZNMEyPmDKnMLLLtq2bs7iNhH a5iFxHjI/HNtxDs8CckOY9J9WoTLZiKh1JxTcL4rpj56FmDt4oFImQdOFZCvoMhos2bB TufA== 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=5Tj9NKTeGMBla53xvh3BcaIduTHMD6Qmd/eOJqwIWw0=; b=AURrlBXYdiAsNX6MwQiTBisUCsIThySSvE18yIQEsxJx63tZcQ+i+NUgVPVC9tToDu vWQkbjTs5cN7iMrr4q/txPl0E8hKJTqymPkwzDbyhoap6gdSC3Oz19Nhrr08sKN8MSWU rg1eARVkm62imjsC0VUlOjCPj3jV8td6THTjCaW+kGTCDEkdPULsdhTKUIE4xTmkcBnf 5M9IoQSkfyHdBQvgzG90E54rNfvU64Gpm05cubSZEFiyPglziNtzYM2CCEMa6v3B2kG2 MSQ0K7oFN4b9RiRRQe/LIsnlz843vHZrCxcd/3k7YoO/SUYbgS8wanxbYmEnLyafnGG/ +hAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=RtxuTnf+; 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 j24si18862559ejd.743.2020.12.28.06.40.33; Mon, 28 Dec 2020 06:40:55 -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=RtxuTnf+; 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 S2504681AbgL1OcZ (ORCPT + 99 others); Mon, 28 Dec 2020 09:32:25 -0500 Received: from mail.kernel.org ([198.145.29.99]:39652 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2504446AbgL1Ob1 (ORCPT ); Mon, 28 Dec 2020 09:31:27 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 63CEB2063A; Mon, 28 Dec 2020 14:30:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609165847; bh=NwdPxoTRoLXPx4dbmmiENSNTu1eNUofaQufCluooSOE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RtxuTnf+aypw9Y1MzpyVWLm7M0DKSBIHgJh0gkvjoAo4wAX+oaEIV6OwTJR0PDl+c hA7NWQfD7QIO/9OXk//bcZkW3wWNbozZ35i20gzQakH9vGkL8QSuIBviHE8A+4dIA2 DA2mIKDW/Zd8VGfU1U0JBj3ETDX9FPJ6maDx876M= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Nuno=20S=C3=A1?= , Stable@vger.kernel.org, Jonathan Cameron Subject: [PATCH 5.10 674/717] iio: buffer: Fix demux update Date: Mon, 28 Dec 2020 13:51:12 +0100 Message-Id: <20201228125053.271255302@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228125020.963311703@linuxfoundation.org> References: <20201228125020.963311703@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: Nuno Sá commit 19ef7b70ca9487773c29b449adf0c70f540a0aab upstream. When updating the buffer demux, we will skip a scan element from the device in the case `in_ind != out_ind` and we enter the while loop. in_ind should only be refreshed with `find_next_bit()` in the end of the loop. Note, to cause problems we need a situation where we are skippig over an element (channel not enabled) that happens to not have the same size as the next element. Whilst this is a possible situation we haven't actually identified any cases in mainline where it happens as most drivers have consistent channel storage sizes with the exception of the timestamp which is the last element and hence never skipped over. Fixes: 5ada4ea9be16 ("staging:iio: add demux optionally to path from device to buffer") Signed-off-by: Nuno Sá Link: https://lore.kernel.org/r/20201112144323.28887-1-nuno.sa@analog.com Cc: Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/iio/industrialio-buffer.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) --- a/drivers/iio/industrialio-buffer.c +++ b/drivers/iio/industrialio-buffer.c @@ -865,12 +865,12 @@ static int iio_buffer_update_demux(struc indio_dev->masklength, in_ind + 1); while (in_ind != out_ind) { - in_ind = find_next_bit(indio_dev->active_scan_mask, - indio_dev->masklength, - in_ind + 1); length = iio_storage_bytes_for_si(indio_dev, in_ind); /* Make sure we are aligned */ in_loc = roundup(in_loc, length) + length; + in_ind = find_next_bit(indio_dev->active_scan_mask, + indio_dev->masklength, + in_ind + 1); } length = iio_storage_bytes_for_si(indio_dev, in_ind); out_loc = roundup(out_loc, length);