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 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B62A9C433F5 for ; Sun, 3 Oct 2021 15:45:33 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 78DCD61AF9 for ; Sun, 3 Oct 2021 15:45:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 78DCD61AF9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Lue14eDutHWeTWDFeB1cloV98nYnuTtbkWHJBcejh1I=; b=K04FyAv08oThyu y+b+n58WI4hvoEo30LUT/zFEpGBrXFbFbjJSjqDGO00S3KCAJ8xviEOsSUxwdlEF4aJ6vX45SKH6k H/g8mQM2sLqnnvpO66IqdnVgEGkCDzR3mkY0vW4Er0c/MEmY0Pds8zp7OY0uNFWjnPgsnT/95S2oQ nYDCPDbwQyRf0/aqrvQyB1XebXI0scuNnwPVQHNw/7PYscLM9gjWzf0uEZflRQxf3iZasud16sA4G SybBV71hQuY7qPEMLf5zEElaFI32ou4yy4m37iS2zf/5GANBDN5M8WvUJwWmm4No40Ugm+uIRlstF HIws5osDjVskxX2fmyfg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mX3eK-003yfw-SA; Sun, 03 Oct 2021 15:43:37 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mX3eG-003yey-Ao for linux-arm-kernel@lists.infradead.org; Sun, 03 Oct 2021 15:43:33 +0000 Received: from jic23-huawei (cpc108967-cmbg20-2-0-cust86.5-4.cable.virginm.net [81.101.6.87]) (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 DB684611C2; Sun, 3 Oct 2021 15:43:28 +0000 (UTC) Date: Sun, 3 Oct 2021 16:47:26 +0100 From: Jonathan Cameron To: Yizhuo , Mugilraj Dhavachelvan , Olivier Moysan , Krzysztof Kozlowski , Arnaud Pouliquen , linux-stm32@st-md-mailman.stormreply.com Cc: Lars-Peter Clausen , Maxime Coquelin , Alexandre Torgue , Andy Shevchenko , Mark Brown , linux-iio@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] iio: adc: stm32-dfsdm: Fix the uninitialized use if regmap_read() fails Message-ID: <20211003164726.42e20526@jic23-huawei> In-Reply-To: <20210808183243.70619aa8@jic23-huawei> References: <20210719195313.40341-1-yzhai003@ucr.edu> <20210724164840.7381053b@jic23-huawei> <20210808183243.70619aa8@jic23-huawei> X-Mailer: Claws Mail 4.0.0 (GTK+ 3.24.30; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211003_084332_455500_1FA92DEB X-CRM114-Status: GOOD ( 31.38 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Sun, 8 Aug 2021 18:32:43 +0100 Jonathan Cameron wrote: > On Sat, 24 Jul 2021 16:48:40 +0100 > Jonathan Cameron wrote: > > > On Mon, 19 Jul 2021 19:53:11 +0000 > > Yizhuo wrote: > > > > > Inside function stm32_dfsdm_irq(), the variable "status", "int_en" > > > could be uninitialized if the regmap_read() fails and returns an error > > > code. However, they are directly used in the later context to decide > > > the control flow, which is potentially unsafe. > > > > > > Fixes: e2e6771c64625 ("IIO: ADC: add STM32 DFSDM sigma delta ADC support") > > > > > > Signed-off-by: Yizhuo > > > > Hi Yizhou > > > > I want to get some review of this from people familiar with the > > hardware as there is a small possibility your reordering might have > > introduced a problem. > > To stm32 people, can someone take a look at this? This one is still outstanding. If anyone from stm32 side of things could take a look that would be great, Jonathan > > Thanks, > > Jonathan > > > > > > --- > > > drivers/iio/adc/stm32-dfsdm-adc.c | 9 +++++++-- > > > 1 file changed, 7 insertions(+), 2 deletions(-) > > > > > > diff --git a/drivers/iio/adc/stm32-dfsdm-adc.c b/drivers/iio/adc/stm32-dfsdm-adc.c > > > index 1cfefb3b5e56..d8b78aead942 100644 > > > --- a/drivers/iio/adc/stm32-dfsdm-adc.c > > > +++ b/drivers/iio/adc/stm32-dfsdm-adc.c > > > @@ -1292,9 +1292,11 @@ static irqreturn_t stm32_dfsdm_irq(int irq, void *arg) > > > struct stm32_dfsdm_adc *adc = iio_priv(indio_dev); > > > struct regmap *regmap = adc->dfsdm->regmap; > > > unsigned int status, int_en; > > > + int ret; > > > > > > - regmap_read(regmap, DFSDM_ISR(adc->fl_id), &status); > > > - regmap_read(regmap, DFSDM_CR2(adc->fl_id), &int_en); > > > > Moving this later is only valid if there aren't any side effects. > > The current ordering is strange enough it makes me wonder if there might be! > > > > Jonathan > > > > > + ret = regmap_read(regmap, DFSDM_ISR(adc->fl_id), &status); > > > + if (ret) > > > + return IRQ_HANDLED; > > > > > > if (status & DFSDM_ISR_REOCF_MASK) { > > > /* Read the data register clean the IRQ status */ > > > @@ -1303,6 +1305,9 @@ static irqreturn_t stm32_dfsdm_irq(int irq, void *arg) > > > } > > > > > > if (status & DFSDM_ISR_ROVRF_MASK) { > > > + ret = regmap_read(regmap, DFSDM_CR2(adc->fl_id), &int_en); > > > + if (ret) > > > + return IRQ_HANDLED; > > > if (int_en & DFSDM_CR2_ROVRIE_MASK) > > > dev_warn(&indio_dev->dev, "Overrun detected\n"); > > > regmap_update_bits(regmap, DFSDM_ICR(adc->fl_id), > > > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel