Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3098756ybi; Thu, 18 Jul 2019 21:00:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqwgZ343u6jv66US6pt+PiWkzYfpNTC4qwkbhGLUGAEEDPEIQk5BGTKd0TEsONQLlEi1dyx2 X-Received: by 2002:a17:902:2ec5:: with SMTP id r63mr53610235plb.21.1563508853007; Thu, 18 Jul 2019 21:00:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563508853; cv=none; d=google.com; s=arc-20160816; b=Rl8pFlE5tlqLD6lTDUmGDgDm3H/FhKQUwtMYP15VkW67v2ABYVwikHMd2lxX8zj8zX xS65XOuPZjBh82hLQIZI04I/vHohxDxa16dBTdvKfBkSSf2s0LoNPaE6zUOCczRi6iHB JXddG5FWV2BmNEJnSVNPBShHhVU+2hArojsQiUIgyTdtaBrOKzDLwnj1dxVC6+KS8dwv jJoi4IM9D+toog3WoxFLzUXN/quiuFEcN5u7VUV5dRAXJtNkCduDnKaNHhSYV1fKqpyd XyJkTeh7WePlR8VWelU908gDYCn/V+G5riW/ZuNx6wODbyPMiO0cOJjFV4AcV6WdtjQN 3s8A== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=F3bS/Bj3Ov1+ILIXrBOPBR+LAyDfAUlTTnaL1jNAhHQ=; b=rUTMENX/vWfNt/eteyc2sJJE9aKgT8/Aqfc9XKljKsb9gszyGaj4wguTUHKEtjxywH w0s+EycODLqUFXkCht14w1ryOrCZsqziTXnWyf07qSLp9g46pvF8dbRDZiJAMqKMopCk PiPTNGOj8I6ra8KT9SuTc6n0HMJj7n162iSE8OsRa5LQT5BKN9/3OFq/ZTo90OZzal3j kI5v06MKqLM2ahVKj+wXltXIpOJ009zM8EfaTnXr3ppDIRW1iD77SCYdUj13oJFS7Ojk YJuM6pjwDe0+edqXC13iq3dWWVgiJ3eoBV97hNOuYLRlo0mUMohvugfKhOdMY5P7s0ab CIDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=bOfgoOxO; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ba9si1041179plb.308.2019.07.18.21.00.37; Thu, 18 Jul 2019 21:00:52 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=bOfgoOxO; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728568AbfGSD7N (ORCPT + 99 others); Thu, 18 Jul 2019 23:59:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:58516 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728441AbfGSD7E (ORCPT ); Thu, 18 Jul 2019 23:59:04 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C605821851; Fri, 19 Jul 2019 03:59:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563508743; bh=B2ai79gdCChTdskBL7ujMCTfm0Vf3Gs/2lF1bhLaAa8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bOfgoOxOdZg87U8nRC/ixQ/LSyyUi6Bynb7/4use0BRxlF7eHWUSKMFlHKHU7nUoR uRlIqWZyINa/9TmOj0TD0bihWAvPyKIS2wRMTvBe/IlTmNbDZwrlHtO4zTDlhtYi/x Qf7rS/SyhJhwBKh+Em3fKGDOIGjI/Rwvp5Ex+1O8= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Young Xiao <92siuyang@gmail.com>, Alexandru Ardelean , Jonathan Cameron , Sasha Levin , linux-iio@vger.kernel.org Subject: [PATCH AUTOSEL 5.2 064/171] iio:core: Fix bug in length of event info_mask and catch unhandled bits set in masks. Date: Thu, 18 Jul 2019 23:54:55 -0400 Message-Id: <20190719035643.14300-64-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190719035643.14300-1-sashal@kernel.org> References: <20190719035643.14300-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Young Xiao <92siuyang@gmail.com> [ Upstream commit 936d3e536dcf88ce80d27bdb637009b13dba6d8c ] The incorrect limit for the for_each_set_bit loop was noticed whilst fixing this other case. Note that as we only have 3 possible entries a the moment and the value was set to 4, the bug would not have any effect currently. It will bite fairly soon though, so best fix it now. See commit ef4b4856593f ("iio:core: Fix bug in length of event info_mask and catch unhandled bits set in masks.") for details. Signed-off-by: Young Xiao <92siuyang@gmail.com> Reviewed-by: Alexandru Ardelean Signed-off-by: Jonathan Cameron Signed-off-by: Sasha Levin --- drivers/iio/industrialio-core.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c index 245b5844028d..2da099badce6 100644 --- a/drivers/iio/industrialio-core.c +++ b/drivers/iio/industrialio-core.c @@ -1104,6 +1104,8 @@ static int iio_device_add_info_mask_type_avail(struct iio_dev *indio_dev, char *avail_postfix; for_each_set_bit(i, infomask, sizeof(*infomask) * 8) { + if (i >= ARRAY_SIZE(iio_chan_info_postfix)) + return -EINVAL; avail_postfix = kasprintf(GFP_KERNEL, "%s_available", iio_chan_info_postfix[i]); -- 2.20.1