From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.43 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796410267; b=3wtT11/I7srFdcVlwNHQ9PpqyPTVSNyCVDfeB3OK6m414kDP9uqBm49tmGXViCHINvdM CM2ID++DUXtz9ee3TXWk8bAhld2rjGF6jYH/pwmKA5kPk4gs+kNE3HlrE8y5mgWCGe6bL YlYV3iianc5mXQXnOt4ABXSsxT/GLmou/JKvin10saCTz3L4M4MfLW4Ykt93i5NjVM8Hs 4agkTU3xkuyM+otqeEp42duJ8iyvDv9yIXZawU13586MkRlCZgt0uyViXBr16EL0rhlN/ /PKAPWYYIvxO+FNARCInumovqCCtrzK/MjnMSzkzBci+O6JUb2KV2r0E0E3pO4IsfZQ== 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=bw6UW4u+5/Uudr4Wvpe9IY4aoh7enkV2mtTRF1T4GX4kr5oaRiJqQBWttm7day+yCe8s Mp3K20ulLsUgElrD0Cn+zGuRCIILhUelNsf74BIWunyUDn+/GhCefUhNAfuagVtqZN92A CuBMYE/o12YQTmAgVFwgdO44MXKljA50UUssje3YdR9NW0Y8Bv4Og8+lxhK5DvhqlM71H WH+XgwQBGiX0Duj5l2RUMl7tgc6KmJKJ1LlSQoipFJ4d0Do2TxPCgY3EQ7Jw3acXlS3ac Hr7SsuEF6lAlVpJtTkjT7LlP6xmHDkvq8O8TBca+lys+igXqHF8NFSuE8pWYJWeOw8g== 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.43 Received: from mail-dl1-f43.google.com (mail-dl1-f43.google.com [74.125.82.43]) (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 41DCE606A322 for ; Fri, 4 Dec 2026 18:51:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 41DCE606A322 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-f43.google.com with SMTP id a92af1059eb24-1b589050416so1524026c88.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=j4X1fPzIHVLv4alAug9mJhzrhFbeYrY4ESkr8OzsxvDZC2ZI6K+OwPUeV3IydZwyLL xF5mowiJsJVQM0B/lNps90Rzz5aSMbxYaaUV+c2hC7C0mAby2b9SER8j72j7EkKVVn/Z O/c1MqplGS03ceJMlO1tVcd2I3q9P5B2YihUk+tGyRgX+0yeJmM8A1WcSrI6TRATuPji FjVMx09/Nmo1MHDPYLIcEMv80kcYs79N3JJt9UMyTrnbz6oZAK1DLkegiLKPsDWygC8U BVpi5sbAYLCEyEk15xd2QcF3HllPd3/MlVvaqgFsfcbHmiF1NXh9DVUq0ihzUqhsh+27 q75A== X-Forwarded-Encrypted: i=1; AL+hErH6xfP7NndTwhrvNWXYE8JL5yS+XaprWGQW7V4+mxVsixuqdM+Fr04pxX0b/vxGp8URWwy0JDHgeEo9jX0=@vger.kernel.org X-Gm-Message-State: APuU4Z9TfODi3HZ090rMHrk30hWDVljz3f0Afef0HcHSZGeasgMruXmS hUpX9haa1KVqEMWw2wMdBGRd/rRQ3L9um86mdllcMk8S4E8nnW8UC9e2 X-Gm-Gg: AZFdTZcgSEqWAP0xDRwkp9SyGJfG6SKfondG2kEk8T7nENsJZkQQVNYatba5mXYadfB etaMAyNE3B3JzPuPZI7gan7RipPBns64HF6tcT3JhPPKaCa548ilPkmES5nAIWkV5cAuUMBLzZL jL5EWZ5SdCZREJ9asqOe43V5BGHfAmzFoEOiS3d+d0JHrCEGW3vrSW/NQH/sjD0F86d90wU6Lre EugbIYUr/AdAKCWpVQcCVZXHntovPivzJiTNhXVDuQfmnQlbHBJDkWRxDEjk8IxFlTltSHPdpNc I8U5K866SU+GuSCWxFErRHa/UfCiq5brATCKAkSpnz0BKiGDXvD7OktxB45rXViQ3TFPLQNHfTj xdKGtYMHi45a562toCS9WXsExFuqMM6OVISKlzc5TPRy4j/kNXuBg3Qx4QbxAjBlci9J6IWmsfY fi4J0Cg76is4tNg6XBkbirl2sG7XKiKFvyyN9lpPYjB6wTrDW1BtwMwJC+uY7RZGUo8NiOQEfsE 1HMKMir/ysVPwDCZSf4R5TMMiJGJ7rpPoeNMHPy9KqO2/p7Visw8GQyi2t7yRicb4IDDWytnbej 0Q8OMzZS1GqEirmN5ffFCQ6fnRhw9XuSQf6XkEok35kcOTnJvb2ljmAG7h0mNrlS8LMhztkrX7j Qmwz2JmjM50vF 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: linux-kernel@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