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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0736AC001E0 for ; Mon, 23 Oct 2023 11:15:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229686AbjJWLPP (ORCPT ); Mon, 23 Oct 2023 07:15:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59674 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232894AbjJWLPO (ORCPT ); Mon, 23 Oct 2023 07:15:14 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E0FD1101 for ; Mon, 23 Oct 2023 04:15:10 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2EE05C433CB; Mon, 23 Oct 2023 11:15:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1698059710; bh=hB43rsEYzW+mRQlTTCVYfaV2IkYMcgvZwxxMW77ursI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MT5tYUhMtC5HDjIKKQQcR/leaVJC3bAz1Q0sh+UEpzpUhcTooXXKzd16Uz+cig6nG DsNyAlQ3N2Meb8JXgyTcYMFgcZLzIsFnDQrOlOPPg2OHR93ycQ2TGG92JN2rFTJZ2m 990a2vGSVCcNn7adoxLQY8e7Va0prtAg/TKCSCAE= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Phil Elwell , Linus Walleij , Jonathan Cameron Subject: [PATCH 4.19 26/98] iio: pressure: bmp280: Fix NULL pointer exception Date: Mon, 23 Oct 2023 12:56:15 +0200 Message-ID: <20231023104814.508369168@linuxfoundation.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231023104813.580375891@linuxfoundation.org> References: <20231023104813.580375891@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Phil Elwell commit 85dfb43bf69281adb1f345dfd9a39faf2e5a718d upstream. The bmp085 EOC IRQ support is optional, but the driver's common probe function queries the IRQ properties whether or not it exists, which can trigger a NULL pointer exception. Avoid any exception by making the query conditional on the possession of a valid IRQ. Fixes: aae953949651 ("iio: pressure: bmp280: add support for BMP085 EOC interrupt") Signed-off-by: Phil Elwell Reviewed-by: Linus Walleij Link: https://lore.kernel.org/r/20230811155829.51208-1-phil@raspberrypi.com Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/iio/pressure/bmp280-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/iio/pressure/bmp280-core.c +++ b/drivers/iio/pressure/bmp280-core.c @@ -1110,7 +1110,7 @@ int bmp280_common_probe(struct device *d * however as it happens, the BMP085 shares the chip ID of BMP180 * so we look for an IRQ if we have that. */ - if (irq > 0 || (chip_id == BMP180_CHIP_ID)) { + if (irq > 0 && (chip_id == BMP180_CHIP_ID)) { ret = bmp085_fetch_eoc_irq(dev, name, irq, data); if (ret) goto out_disable_vdda;