From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 79BF4357A4A; Fri, 9 Oct 2026 14:52:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791557553; cv=none; b=Ru/9/uaIB8Efe+TntKFg91HmYg/IDK0ZdSWGT1W6aKg5m3mMPauS2EV47Gazwkqpd6uY9mlnPn7BAFORzJVOtx4udAR3NP8EN9Cb3Gf99F7pmmZnXKMxpJPyoMa5W0j9avTSNORr6xhJjBocP2ZwID8Eq4aYBe/8vJNjW/FK5eA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791557553; c=relaxed/simple; bh=WIrhjr/UHOqQfA6IkDpZzWqoVC87nO+wCKDMtnnkCfY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ssftqmn9U2DZTnbu4WYSrgTZaSpRPCA9oqWi7DHTuGazaxdSVWQ5fcfQ16BL/xgfuT1psi7CH1+jcC8CGNQy55AHeMv3ZhSxCYVgayi3f9XHxDw8P5Pg9WP8Cqyw+u2v0/7UTDRg5i9nZ0FiyfuCadd1cFawEm6uFf/owFHOmjM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Bqenz364; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="Bqenz364" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D3B3D1F00893; Fri, 9 Oct 2026 14:52:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1791557552; bh=F7MPFG1bitUhzjfhdeze/SKjhWmK4HIXLN0zDpgkxWY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Bqenz36488yfPCywBWLUQAYXYzrR57yMY1oXLxvPZk/AaF6FXbpD+xnV205CxBztp yv1qkj22VKv6s4AyqfeeFVR/Ds3JueqPGCDlDsKRSn3JK9925bnuETnHyyBoJHLp6v KYUy9Yvv8Bp7ttBFeGrjf1PmWxLt3PWQMDR/ZZ8U= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Jonathan Cameron , Marco Chen , Jonathan Cameron Subject: [PATCH 7.2 401/428] iio: health: max30102: fix NULL dereference in interrupt handler Date: Fri, 9 Oct 2026 16:12:18 +0200 Message-ID: <20261009140955.024030565@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261009140946.008206689@linuxfoundation.org> References: <20261009140946.008206689@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.2-stable review patch. If anyone has any objections, please let me know. ------------------ From: Marco Chen commit f0ea4824deebf21dacfbe397c4b0a5fd3e745a8d upstream. The interrupt is requested in max30102_probe() and stays enabled for the lifetime of the device, but indio_dev->active_scan_mask is only valid while a buffer is enabled. When an interrupt arrives while no buffer is enabled, the handler dereferences the NULL active_scan_mask: Unable to handle kernel NULL pointer dereference at virtual address 0000000000000000 Call trace: __bitmap_weight+0x64/0x98 (P) max30102_interrupt_handler+0x48/0x160 [max30102] Call max30102_fifo_count() at the top of the handler and return early unless it reports a FIFO sample is ready. Because FIFO_RDY is the only interrupt source enabled in max30102_chip_init(), an invocation of max30102_interrupt_handler() without the FIFO_RDY interrupt status bit set carries no data to read and can return before touching active_scan_mask. A negative return from max30102_fifo_count() indicates a failed interrupt status read and is treated the same way. Fixes: 90579b69e94b ("iio: health: max30102: Add MAX30105 support") Suggested-by: Jonathan Cameron Signed-off-by: Marco Chen Cc: Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/iio/health/max30102.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) --- a/drivers/iio/health/max30102.c +++ b/drivers/iio/health/max30102.c @@ -290,9 +290,15 @@ static irqreturn_t max30102_interrupt_ha { struct iio_dev *indio_dev = private; struct max30102_data *data = iio_priv(indio_dev); - unsigned int measurements = bitmap_weight(indio_dev->active_scan_mask, - iio_get_masklength(indio_dev)); - int ret, cnt = 0; + unsigned int measurements; + int ret, cnt; + + cnt = max30102_fifo_count(data); + if (cnt <= 0) + return IRQ_HANDLED; + + measurements = bitmap_weight(indio_dev->active_scan_mask, + iio_get_masklength(indio_dev)); mutex_lock(&data->lock);