From patchwork Tue Jun 23 19:53:21 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: 223184 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.0 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 550DFC433E0 for ; Tue, 23 Jun 2020 21:22:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 24E2A20724 for ; Tue, 23 Jun 2020 21:22:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592947333; bh=XdGr7wo88QC1X3JLceRhGU8zIUMPJFkCeqfIKIEWxec=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=DldXC2Y4RwSwv4daHO+J0/rl1XGDY3mQ/NcNPKwouG6nHz4jZqyK3ATfIss4YrlkQ WRxvPnMEOmMSXcEWh5dcG6EpZlr0cjjy3fT+I4dbWVZ19DJREoasm5emSE5L+luBVz 1H3ruGTYvYE/ZRCKmVs5iOZWZJaog/c5UCAFwss8= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390142AbgFWUWW (ORCPT ); Tue, 23 Jun 2020 16:22:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:40234 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389379AbgFWUWV (ORCPT ); Tue, 23 Jun 2020 16:22:21 -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 6AA9720780; Tue, 23 Jun 2020 20:22:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592943740; bh=XdGr7wo88QC1X3JLceRhGU8zIUMPJFkCeqfIKIEWxec=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BnVFvYX0MHhinOAMMB5jKdIWuuXAPGX+WOB18OZxZE2FaassNIr3GaLcr3+Sihd9t OvkmpnHHtfA0FHBJRTlhHnpSsCpGKJHuQm7sBLFsH59qV3rMLUKYav1kwjZxv6xc16 CO4oG8TMk3fjegWXxhbGISpuluzQ5Gea0tM7XvOY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Andy Shevchenko , Linus Walleij , Jonathan Cameron , Sasha Levin Subject: [PATCH 5.4 006/314] iio: pressure: bmp280: Tolerate IRQ before registering Date: Tue, 23 Jun 2020 21:53:21 +0200 Message-Id: <20200623195339.086909780@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200623195338.770401005@linuxfoundation.org> References: <20200623195338.770401005@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: Andy Shevchenko [ Upstream commit 97b31a6f5fb95b1ec6575b78a7240baddba34384 ] With DEBUG_SHIRQ enabled we have a kernel crash [ 116.482696] BUG: kernel NULL pointer dereference, address: 0000000000000000 ... [ 116.606571] Call Trace: [ 116.609023] [ 116.611047] complete+0x34/0x50 [ 116.614206] bmp085_eoc_irq+0x9/0x10 [bmp280] because DEBUG_SHIRQ mechanism fires an IRQ before registration and drivers ought to be able to handle an interrupt happening before request_irq() returns. Fixes: aae953949651 ("iio: pressure: bmp280: add support for BMP085 EOC interrupt") Signed-off-by: Andy Shevchenko Acked-by: Linus Walleij Signed-off-by: Jonathan Cameron Signed-off-by: Sasha Levin --- drivers/iio/pressure/bmp280-core.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/iio/pressure/bmp280-core.c b/drivers/iio/pressure/bmp280-core.c index 8d0f15f27dc55..084a1d56cc2f0 100644 --- a/drivers/iio/pressure/bmp280-core.c +++ b/drivers/iio/pressure/bmp280-core.c @@ -706,7 +706,7 @@ static int bmp180_measure(struct bmp280_data *data, u8 ctrl_meas) unsigned int ctrl; if (data->use_eoc) - init_completion(&data->done); + reinit_completion(&data->done); ret = regmap_write(data->regmap, BMP280_REG_CTRL_MEAS, ctrl_meas); if (ret) @@ -962,6 +962,9 @@ static int bmp085_fetch_eoc_irq(struct device *dev, "trying to enforce it\n"); irq_trig = IRQF_TRIGGER_RISING; } + + init_completion(&data->done); + ret = devm_request_threaded_irq(dev, irq, bmp085_eoc_irq,