From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.44 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796410267; b=elwdoiuqjBMzbB25lvWb07CDZGXeR+voXL2k1sBQZcQyDoZZOw8RKf7z5LGi16EuEbmt ec/c0l/+s7Kdpp7z4l8E9+hnWh65sby+XQ5xJNfAmyPrtagsR7a/IUnkf9y0BbItulXJA yvGEyHQh3r6L92W/tNbmMsbJqLwHKk7DIjlTHVLN/JfagD7jnln4asusQH90QetyPGil8 mCbFggJQurMgt9sXdSeazR4Mfn7Vl9VQB3KzZaBunxpxz90M3poyEQW9eUDH7zgNB93At aLaVXLNHj+wRAODcUOdfL3VkiWyk7nsNjottBrnD6bdvmoCxA0GPphLEgx+stIQZW8g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796410267; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-Id:X-Mailer:MIME-Version: Content-Transfer-Encoding; bh=DZjVHYX0kMmwqGFpjnfMApfDMaxQk161/JOLKQ/NDas=; b=Kzv3+qZylVQKdss85kbGxi0BLjCVQ6P2z2R+1VXRhwz52OT+ZzIaDhJJ1S7Dn0PKxlAZ O5wK2ArZjwBy5ItThTiuqACp40FUvDjV6S6VLzfrmRtzGrk/aBHTba5mOP9M6o7h0T0/9 M6VXD91QD1PS/YEDX0o4yH7FxoYYc2qAq0/Cm1nPo++ENpJl73CMFd6/ETY9cqupvC/eW lHKp4sLi/sNQsoCKqARPt7drXKfcdDEPCSSwRWmGYX2Fwunt97TVQQHLqgXcWvpeI3E2S 9uJkjFxgIw2Lf7Sh2K0p/nEd8Gy0fsDJrHF67fD4Y1dVq6GNZCboWTFbva7EgeaYTMA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=ZpUisxk+; arc=none smtp.remote-ip=74.125.82.44 Received: from mail-dl1-f44.google.com (mail-dl1-f44.google.com [74.125.82.44]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4B048606A32C for ; Fri, 4 Dec 2026 18:51:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 4B048606A32C 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.a=rsa-sha256 header.s=20260707 header.b=ZpUisxk+ Received: by mail-dl1-f44.google.com with SMTP id a92af1059eb24-1b589050416so1524025c88.0 for ; Fri, 04 Dec 2026 10:51:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796410266; x=1797015066; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=DZjVHYX0kMmwqGFpjnfMApfDMaxQk161/JOLKQ/NDas=; b=ZpUisxk+mmV0qkymqR88j6aT9pwV0WsoV9sECOi1lfsylgP8MxH6sUe685azH1R6qG 5fCG3OVZEVG1G68vZix5dt92BR9KXwPSmi+lFHEdLFaLX69+mnYOoRWirCZMzx71kZWy 128tPHSwbetz6X5r+lRpgogj/E/9+Gi2uhF3oCds1EsKpe9tB5x845qQQHtpbewj4b3P 4ppJ+4X6Jr7Yci+V2us3czeu7bEko+pO/KTMvO4SSjxdD/tLIiKCmKW9ExIYFt6DYnSE qESmyKKb3Z250xI8EKeYEJLk8ElofB25IlLs3YF/N6CS7Opwy+6hgGuj8toXeqWdXNSd XDVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796410266; x=1797015066; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=DZjVHYX0kMmwqGFpjnfMApfDMaxQk161/JOLKQ/NDas=; b=Eg+8EEFKuhPMwpNFLOvzyhNptyABU+JwZlauuwp6JKSeMOYSpr6oST8lfbespfJtqZ leq8a3CvpCgxqLFgXzrMvAt71XfhOlrzBsHGb2Dt3qD3pPhTH4J6Mn9hNsncdvEQBIJL qDWlUxTe2tRuAT/QZuAvf3l4NsnAU0epUkMnlPxzgUGb37LKjEWwbeF4cK1afXTfox6K FIpRPpsgBLLf2+HVBZDDjEE7ok/K5u1XztQwhqPi+meCFWzwXxFuP2SkOCjWMZ4vJilU 8+ekcSQRTMfWw5fj2d/O4z8eFEqlWwKz/5lBHJ3DNHxrpgOAaBLwSj+XTUPC/vzyypPZ 57ig== X-Forwarded-Encrypted: i=1; AL+hErGvhxi89if2nJUfV7cKo9RS0P1MKQqeB/FiecCrSSw4N3+0A5redaQT9bo2tIT4h4UH/5RZpME=@vger.kernel.org X-Gm-Message-State: APuU4Z8gTItjoMStM8alVE+dDeQr0F8509YT1dPUUmRTFPlH1sj9A69S VtZiBlYNm7UI1iZsvsZ98pPvJEfHxkY9gXQp311EJv7N00kfrgRZ1+hwKNVKe8lm X-Gm-Gg: AZFdTZcVkPJg5o89elwP0t+YImuVsnZSTUw4ILPiBT5QGkW+W31fd+EZc7BtT8Mrq7S EmjDwrmUJc+dtEfdY4UyzBOiTe07Ia21KhE9cvceqnxT6DaEwOUIb4ImJJiE7DeY6aQTkoDeCir vGNNNMMj19kMGaUhwIM56E9orpUvzu5kJzbMFvUqh/bdyN5O/yXVA8q/SpKS8BChXZ/+vgiWHDa FHhgAEYB9oUfpnFmEqvpcUcBcY9WfTQ3cCr/Ab+nswGGCFiJdpQxjfjar8vqTN3SA5SgQEPs8Kx Tcbxr0eHh0lLd3Ox9JT7rzKu3ztglwRJX3JWNTyt4rcmM2iB8EKXSOeLrR5WI9ucsH5hy79qice Xk1GYH5/ywv1nkJY+sNgv8jxPUP1BKGb7fAwsyfa0R6Ox7SbZuhi8DoK2/r+B/RKWkBzaOCBEYL buHRR2MmntZo2zq6PBr771AXiJSxj/WsjeeXCH994QcqyluDDTJmBU92Z76dg98x7RfLMPeS7p0 3YCdhU0CmcX6yV6vjlEV7JKr902At7aQ45M5S8n/prhrlMh+MLVjlgaTMEa2GzXBJbWYf2jOM6b Hz8UB8+TdbF5VgyLeLdHc5Q22rakHhstObxn6ys014bUZZBwvc5s8TBGgIXGwhD6FX8MI/smsE9 l89V/QGFbK7kr X-Received: by 2002:a05:7023:a5b:10b0:1b5:d269:285e with SMTP id a92af1059eb24-1b5d70e6a11mr2247084c88.19.1796410266349; Fri, 04 Dec 2026 10:51:06 -0800 (PST) Received: from localhost.localdomain (wood.seclab.cs.ucsb.edu. [128.111.49.37]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-1b5d646ce0fsm8463583c88.12.2026.12.04.10.51.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Dec 2026 10:51:06 -0800 (PST) From: Praneeth Balasubramanian To: Greg Kroah-Hartman , Arnd Bergmann Cc: Jiale Yao , linux-kernel@vger.kernel.org, Praneeth Balasubramanian , stable@vger.kernel.org Subject: [PATCH] misc: bh1770glc: Hold chip->mutex while reconfiguring the chip on resume Date: Fri, 4 Dec 2026 10:51:03 -0800 Message-Id: <20261204185103.1687865-1-praneethb2002@gmail.com> X-Mailer: git-send-email 2.25.1 X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit bh1770_resume() reprograms the ALS rate, the ALS thresholds and the proximity mode with bh1770_lux_rate(), bh1770_lux_update_thresholds() and bh1770_prox_mode_control(), and sets chip->lux_wait_result, all without chip->mutex. The comments above these helpers say that the mutex is held when they are called, and bh1770_power_state_store(), which runs the same sequence, holds it. The threaded interrupt handler takes chip->mutex and also updates the thresholds and lux_wait_result, and device interrupts are enabled again before ->resume() runs. Without the mutex the two can interleave and leave the programmed thresholds or proximity mode out of step with chip->lux_wait_result and chip->prox_force_update. Take chip->mutex around the resume sequence, as bh1770_power_state_store() does. This is independent of the pending "misc: bh1770glc: queue proximity work on freezable workqueue", which keeps the proximity work from running across suspend but does not serialize resume with the interrupt thread. The missing lock was found by a static check that turns the locking rule in a function's comment into a Clang context-analysis requirement on its callers. Fixes: 190420ab34ab ("drivers/misc: driver for bh1770glc / sfh7770 ALS and proximity sensor") Cc: stable@vger.kernel.org Signed-off-by: Praneeth Balasubramanian --- Notes: This was found by a compiler-based check, part of research at UCSB SecLab. The locking rule stated in the kernel-doc comment of the called function was turned into a Clang context-analysis requirement (__must_hold) on that function, and Clang 23 with CONFIG_WARN_CONTEXT_ANALYSIS then checked every caller. An LLM was used only to turn the comment into a machine-readable rule; the report itself comes from the compiler. The patch and changelog were drafted with Claude Opus 5.5. I reviewed the patch and take responsibility for it. Testing: builds without new warnings with W=1 (x86_64, clang 23, allmodconfig). Not runtime-tested; I do not have this hardware, and I have not observed the race myself. drivers/misc/bh1770glc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/misc/bh1770glc.c b/drivers/misc/bh1770glc.c index 26bae1aec423..1d5197f54aa6 100644 --- a/drivers/misc/bh1770glc.c +++ b/drivers/misc/bh1770glc.c @@ -1319,6 +1319,7 @@ static int bh1770_resume(struct device *dev) struct bh1770_chip *chip = i2c_get_clientdata(client); int ret = 0; + mutex_lock(&chip->mutex); bh1770_chip_on(chip); if (!pm_runtime_suspended(dev)) { @@ -1336,6 +1337,7 @@ static int bh1770_resume(struct device *dev) chip->lux_wait_result = true; bh1770_prox_mode_control(chip); } + mutex_unlock(&chip->mutex); return ret; } #endif -- 2.25.1