From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qt1-f169.google.com (mail-qt1-f169.google.com [209.85.160.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 00FB92C21F0 for ; Mon, 3 Aug 2026 04:13:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.169 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785730423; cv=none; b=BMg3c1k8s0nMdsTgNwlzO8YZym2/kfREvjHdVk6MGB3Y/D1npMDOw88H5aoM/HNW0UrP4StPDi0g9WABPYiSLmjMokDxLaxx7hCUdEFegI0qsD0hkimT+6+eKfqa13/VlFuKQjy8otahXA0MrhkpvSWGMJldpnZRyolz/giCzI8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785730423; c=relaxed/simple; bh=OXLpzJ/H2u+nL8XvKhNKq1KQkvmcRXmXu4aXTGY55VE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=rBvt+ExhkCOUjOPCCQVtR4owc++ewujVP0TP4nGJaGlbbW521Yiktu1VWeI6F7FzmBSAtrIlnImUIKMvkhn2vEtlFwj89dcHhhouy5ParLRq3vR37ITSrU5DH6YXn0JvondoC/B+wyJXFT5oFq5yKCvE6cW/lYOQZ6bTxKM1wxk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Nk4Bxvdf; arc=none smtp.client-ip=209.85.160.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Nk4Bxvdf" Received: by mail-qt1-f169.google.com with SMTP id d75a77b69052e-52b3934af3fso28276631cf.1 for ; Sun, 02 Aug 2026 21:13:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1785730421; x=1786335221; darn=vger.kernel.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=pl04dpRgnSLOgJC5HtXDz9EzCs1SLg5wxfFNPj5wzoY=; b=Nk4Bxvdf2jQbqjXHfiJwFk5ZswpxSbinO5qYF5MX53A/07Qj/CVGowX1GPONP1JVdP E85xCGMakVUMySZgkcjshLD3AXlCwec+CJvxGqJ5csSo8wBsSeo8M1ZbJ/TtcJ9VeCAa iZSPQlkKq9/ZBREVlGS00BYW9gH61xTAkdi7YhXSav+qwDcKp6K58Bb7Z2qGyJTW2k1G 7NIJYsj/70+RRmOnfHSgkLmd8uO/nR1H3w++aRDX3gwSHLFjpgYv+c1kepJTnbSkdyrx eAxfWYMaUvHoK28kHTZZHsPiVGMjanODR7DJGbFanq/4DZ5ZB8AQlrAafb6GRQBCxxhJ colw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785730421; x=1786335221; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=pl04dpRgnSLOgJC5HtXDz9EzCs1SLg5wxfFNPj5wzoY=; b=ZLuU6R/+MbzyVgKIpCBSA4D3pe+RwQ1ckDBvB8eaajrRy1CngMgzig/e5gXCa1ESpL vzMmoFq8itifxtUopEV8bk0IKQE7eyjSg/c8LnXFEMW9U6VTJBfCNK8iujwgbFf/mybg nALuPxf8CpmymWchFFiXFJzMtzy/pclUaYX5P5VIbrLA2yR2WMAg2H3YQW5WlpdFyoVe 08bJ7INeRFaN+tbPXIUn2iU6Bo84xLegNmp8rZXXnqNc+7d1PYIURK++SI5LvG2Z1JiV wOc4GUMOOf+LJKKiKpoATz8r244q1dgnE02mgbaPNLDHrfCvYsi7Z8TD01mqx0usaAEP cWHw== X-Forwarded-Encrypted: i=1; AHgh+RrdAQGuAbmXiylX9W9fbdCNB3zip0PTZtDV9SXDo0hk/EJMjImiVY8EtFc0yeshYSjQvjW0Q2/IjP6leCc=@vger.kernel.org X-Gm-Message-State: AOJu0Ywmq7oN6yb8DdI/KK8niTde9jiV7RE54g+/12Sd5UFBPe3ogMr8 TgtoU2KjUhM/7Supx9FO+HP0lVszEShr8wwUJbGkK5EC3w7qiUOrELQAqyG5KlD2dsI= X-Gm-Gg: AR+sD12IQZ0OB9Qi1xYuoJZ4z0jJhu47Hd8+PjpKwYaxTn2KGfWii6+N7//vA2E49iL XgbLbcHfkAuvQkmaurxrnQa6lPjf6GR3hjLvegJtugA6J0OmJn9DCPPG0vtdgm/b8IjKT79qKoG iDCOmDulgr9lZJVXP6gCadFjkszcVJLcWoIGySjUYq4MBu6JX7oMxo2iE5KPGP9R2KADCVxtEPu uTT8e9MwcarL9JOEWPOfxnYUtQ1ykrgzwSXH7nlpYHES6Htsywyj0ZCmX5Ivu8/Gwb8+fcdwSDW f5u3S2Zu0Q7+97i3F5s+o3c/lcIKa45IrA4zwqrbbawdUbDAm9BygT5juQaqMEwn4cDarTV3Smr H68t5c4ivXf3WTYzh9PcxuNiS+cPd0ZTFvxRxCweehJuBFpHvwTF/fFLbKdIJehNaCCtTCdWsKW sGSeCJ+Lbn0WmJbinsrSdjQQiD6DMOIaatMNxteNSgnwuxI4jyl711Xk2xlOB8z8pH+Pw= X-Received: by 2002:a05:622a:44b:b0:51c:1fd1:e755 with SMTP id d75a77b69052e-52b567915e7mr145099021cf.36.1785730420860; Sun, 02 Aug 2026 21:13:40 -0700 (PDT) Received: from localhost ([2600:4808:5693:8201:bb19:d9f0:6e53:91ed]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-52b4eb6a857sm52935101cf.17.2026.08.02.21.13.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 02 Aug 2026 21:13:39 -0700 (PDT) Date: Mon, 3 Aug 2026 00:13:33 -0400 From: Marco Chen To: Jonathan Cameron Cc: dlechner@baylibre.com, nuno.sa@analog.com, andy@kernel.org, pmeerw@pmeerw.net, matt@ranostay.sg, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, skhan@linuxfoundation.org, linux-kernel-mentees@lists.linux.dev Subject: Re: [PATCH v1] iio: health: max30102: fix NULL dereference in interrupt handler Message-ID: References: <20260731184124.112124-1-marcochen.dev@gmail.com> <20260802032609.27900bb9@jic23-huawei> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260802032609.27900bb9@jic23-huawei> On Sun, Aug 02, 2026 at 03:26:09AM +0100, Jonathan Cameron wrote: > > + if (!indio_dev->active_scan_mask) { > > That is racy as this could be going on in parallel with the buffer being disabled > so we check here but it's gone before it is accessed. I understand what you mean. I will remove this active_scan_mask check. > Which leads me to suggest alternative fix - check INT_STATUS and if nothing > set it isn't our interrupt. That doesn't get into the potential buffer > enabled / disabled races but should close your condition I think > - looks like it is read in the fifo part below. You may need to refactor a > little to not read it twice. This makes a lot of sense. For the v2 patch, I will plan to read INT_STATUS once at the top of the handler and pass that value into max30102_fifo_count() so it is not read twice. Consequently I will remove the INT_STATUS read from max30102_fifo_count(), too. For checking INT_STATUS to see if it isn't our interrupt, instead of checking if nothing is set, I was thinking to check the MAX30102_REG_INT_STATUS_FIFO_RDY bit specifically because that is the only interrupt enabled in max30102_chip_init(). This will close the reproducer I was hitting earlier as you said. Since we only ever reach bitmap_weight() when FIFO_RDY is set, the NULL dereference is avoided. I think there is a theoretical window if the buffer is disabled between the FIFO_RDY check and bitmap_weight() call, but as you said, closing this would need the buffered mode claim. I plan to leave that out of this fix. On Sat, Aug 01, 2026 at 16:18:00 +0100, David Lechner wrote: > This is one of the reasons why you are supposed to turn off power > before moving wires. ;-) Fair point, I was pretty careless. > IRQ_NONE would cause the handler to just run again as soon as it > exits, so it is almost never the right value to return. IRQ_HANDLED > is correct. Got it. I will keep IRQ_HANDLED for the v2. > There isn't anything we could do other than log the error. Understood. Since the INT_STATUS read at the top of the interrupt handler now determines if it is our interrupt, I will check the return value of regmap_read() and log the error on failure.