Received: by 10.223.185.116 with SMTP id b49csp657529wrg; Fri, 23 Feb 2018 04:53:19 -0800 (PST) X-Google-Smtp-Source: AH8x224LykiC7FhhgawwWlYBSunFnO5QFRPCer/Ol+Ue6KxrxBtM3G+ivihynueYGhslJ/lSt6mS X-Received: by 10.167.130.88 with SMTP id e24mr1669627pfn.169.1519390399696; Fri, 23 Feb 2018 04:53:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519390399; cv=none; d=google.com; s=arc-20160816; b=kCSI2P5bNIH0hIPyjWxMwWyuiQYPylWcjQwgG5rKTZe9d/g/Pf+g/usicFxReSGiF2 P/r9Y6vEuRtpdRFQu78Pb2k2Rw8+VIuVWBB7boPFjFIHZWc6C1ahoVI/Q0EYiNWuyvgc 8Yk0blsaXdGkTy8ophQsMHPgmyC+pEyA0jUEN3GMCObA0X4Jq9CyABOXSxQUDGrqvPH1 5gb1gq7/7CJG38JrgSkQ3MxnwezHA344J8rMCpqAmHbvfSarIEN/GmQh34qXgPknFDHA il3hdyXzTcjKEDv2Sv2Q8FumaAr4B1zbrdj6rzXYD4km/J9EEZt7A9Hmxp8T7g2lfGgp vE2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=CNLcEeH/jMYx5oI7yyWr9lpDaq89p5KTIB4VhFouhMo=; b=0VVPt2DZJLqUsphlqWQbYyIB0RyEe1tD2zzg1KpDWgNFFDFMWplnlYsfmBotRnyH4K DROEUgxFwGh91wMUNRz+Dz46G9r0GXcu8WV1MeYd0z5n1Dm3NlgeYp+h9YtQ1Y11xPgF rmQ1XVRyGPxiIsh4bLXEOnsd8NUEOwJa8Bc4i48aj8knTUgNP6XWSJvcXqhB32hDBkVI 8ly0GC2If2PdYajkbJW1nIb17Kk6/5iwYZOJqzSlKNs0MHSd0awFs5Q1Pu76oenL27Zk XW5cL+EWHQnUAlsPwIjz7vdEetR1/crU8zfVqzZ7p3tE4yPbyZKeT37IjMWUN8/ua16n IytA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d18-v6si1779721plj.438.2018.02.23.04.53.05; Fri, 23 Feb 2018 04:53:19 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751617AbeBWMwR (ORCPT + 99 others); Fri, 23 Feb 2018 07:52:17 -0500 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:53978 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751586AbeBWMwQ (ORCPT ); Fri, 23 Feb 2018 07:52:16 -0500 Received: from pps.filterd (m0046661.ppops.net [127.0.0.1]) by mx08-.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id w1NCnG2V015307; Fri, 23 Feb 2018 13:51:23 +0100 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx08-00178001.pphosted.com with ESMTP id 2g9bpka35t-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Fri, 23 Feb 2018 13:51:23 +0100 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id A052038; Fri, 23 Feb 2018 12:51:22 +0000 (GMT) Received: from Webmail-eu.st.com (sfhdag5node3.st.com [10.75.127.15]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 89C534DB7; Fri, 23 Feb 2018 12:51:22 +0000 (GMT) Received: from localhost (10.75.127.46) by SFHDAG5NODE3.st.com (10.75.127.15) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Fri, 23 Feb 2018 13:51:22 +0100 From: Fabrice Gasnier To: CC: , , , , , , , , , , Subject: [PATCH 6/7] iio: adc: stm32-dfsdm: add check on max filter id Date: Fri, 23 Feb 2018 13:51:00 +0100 Message-ID: <1519390261-25453-7-git-send-email-fabrice.gasnier@st.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1519390261-25453-1-git-send-email-fabrice.gasnier@st.com> References: <1519390261-25453-1-git-send-email-fabrice.gasnier@st.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.75.127.46] X-ClientProxiedBy: SFHDAG1NODE3.st.com (10.75.127.3) To SFHDAG5NODE3.st.com (10.75.127.15) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2018-02-23_04:,, signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org reg property should be checked against number of available filters. BTW, dfsdm->num_fls wasn't used. But it can be used for this purpose. This prevents using data out of allocated dfsdm->fl_list array. Signed-off-by: Fabrice Gasnier --- drivers/iio/adc/stm32-dfsdm-adc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/iio/adc/stm32-dfsdm-adc.c b/drivers/iio/adc/stm32-dfsdm-adc.c index 57bcb45..1b78bec 100644 --- a/drivers/iio/adc/stm32-dfsdm-adc.c +++ b/drivers/iio/adc/stm32-dfsdm-adc.c @@ -1111,8 +1111,8 @@ static int stm32_dfsdm_adc_probe(struct platform_device *pdev) platform_set_drvdata(pdev, adc); ret = of_property_read_u32(dev->of_node, "reg", &adc->fl_id); - if (ret != 0) { - dev_err(dev, "Missing reg property\n"); + if (ret != 0 || adc->fl_id >= adc->dfsdm->num_fls) { + dev_err(dev, "Missing or bad reg property\n"); return -EINVAL; } -- 1.9.1