From nobody Mon Feb 9 21:00:32 2026 Received: from mail-wr1-f46.google.com (mail-wr1-f46.google.com [209.85.221.46]) (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 689E430C377 for ; Thu, 23 Oct 2025 10:29:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761215353; cv=none; b=Uq7PoyMBNZRl9FMyIbmQqOqnyxVxctWGSKS6gmtKW1CJHXgwrBjz9pAoD4m4/YGiutY+Cjj2428z7w+Zxm6QEvVuPXkMUJaeRFJXKOZc9MCr13+vNTIczgGWsH/ScWhG/AAHzp3mLln1tSyYMCdUgCSBWn8HetcWiAiKWL8BVKo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761215353; c=relaxed/simple; bh=pluT3fe/JrETSIHHgu8mtUlYeIruYoNzHyfoBOUg2eg=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=gRympcBqn0JX5SOpu5/+ibO8IRem0jJVeomtSwd7o0JPdwJBxtL6JNiW3HXxAxKY4ICkTPx0qCoNiy7PDV99iPk8i04f6NfHdQqTvPg+nXtJokmRWXqwinvj6Gy/id6pmoGvYrE/IQBec9Qcq8iO22iz73CThj6cQuJ5c2VcFqw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=DYrAgg0M; arc=none smtp.client-ip=209.85.221.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="DYrAgg0M" Received: by mail-wr1-f46.google.com with SMTP id ffacd0b85a97d-4270a072a0bso120789f8f.0 for ; Thu, 23 Oct 2025 03:29:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1761215348; x=1761820148; 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; bh=NHJKzwfxsuuIDKuJ2Y7MxCWL8cdo6xWLdj43JgzP38U=; b=DYrAgg0MyQHo7Bm7OUT96PTZNeNOtJHh9yLUZauxKO2Lx9kiaZBewwlj+Soa+RP/aK 6FEfmbW4isiSa2MoIAgv3BvDvTnpH0lQTpjVrmCmPUTgY4wvW7KXRFSSNnbpBFkk8oF9 s1Y4VXZVZm0nUWMWhJWx5n6v7ETnnC1cdj9tGmlmvYK0Rsp2Ls6kANhX38s7jihLUQPk 0WuPypPNPWm6Hh/BSPMWGZfW/VLasO4rC+G1iwY1HJGsPa4qoWxmxYmyLA9+mgLQ/zPt QKN2fFeJV0QESDqeD8ka9xbTHDjXCwzEGLsVD0PKWgFVbaQIGHOxOISbAiXcOXROh71H wN0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761215348; x=1761820148; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=NHJKzwfxsuuIDKuJ2Y7MxCWL8cdo6xWLdj43JgzP38U=; b=McbsEISVSzvQEllO7Oh1sG0iDQ0aPaMcpF7H91m+8bJ9XAtDPgbsIB8eCTwCilLQOK kyQ9LRuPEsqhAatizEzFxMp1thuak1jW6p/JWe8Ai1IUzWufNG1AsUOu36hZfFdG+5oL KieO0X0nRMkLAK6PYoYi7soNJcxC51f29fXsDloNwNS0vwfN5/cdPc/i0lTSgeZuwYPv 0E42md/SH7TbpKT+67t/WV8GGhFOAEoEurMtbT5S2Hf3H51eysal4DNtUlhsZWUGotIS BpyRVpFt0B1kXMVdSseImAcIV5102AlwZPk16ikPJlnTh44vi9dcVtHdssaGtNHwxczl fB8A== X-Forwarded-Encrypted: i=1; AJvYcCXm0ANbn1MNf4UEiXzGX0hTcxD5dcEJmwudsxHnB5xfQOz9oLS+hydXEpt6nSlo3kl6OFN6ysWRaYvlsGI=@vger.kernel.org X-Gm-Message-State: AOJu0YyorCZkVAHECfsqUIkWScWiAaNlbipIaCOLPc780qSXDlggLoZ4 ReVnhHOmnFGSSP3tqgD+0233ma5p+1Tnyk5rfRLWNlkjlUmIPC6xhB+SmnGgclQW1eI= X-Gm-Gg: ASbGncvNAvAOzcm+prVTCXu0SOX98OCMFVqxTxwcARSgxljuE2mJMghILefATn+QnMn UDcbl4V3jBiOU9oRDGQ018wliR0TXyGiQ8TB6NM03MBu2H8GP/56x85atu3+NpSVAmi4uXkf+2z F7or+BRBUIbsB9VFi+J2Yq5hc+vkHhFp30M+hJgT6s8JzPl5jw53tP7Y144yc7CfEMUCM6xPEtt lmtAblmdbipLWDOEShCV9nMWoicX5Pe6DtRSVcKAdHp23nhEX82YjU22CSYEYOm+PhxJZhaQv+X 5/FXxcMpOcRmVu4tDuwYWAC44qW+9uFWAy9wllgVG+iZ7Ae84LlZXU6n4zxRJDo6sJB3bv51I+A 2IG5Ok4LqrP2WTY8X668cq2VMym5J3ajHMmtRzJrPmK8JWABvlAnEF7UHDS770Aetf7kTITh2zR 4N5GG+p0olm3k= X-Google-Smtp-Source: AGHT+IEpZ5MhhD+4VmCipbsuMXBPQNWZTP9mAos6+Z9IvudfJzgjQzAoyUcSmbnGkZ8yQ+8VCn1FXQ== X-Received: by 2002:a05:600c:1ca9:b0:46e:2562:ed71 with SMTP id 5b1f17b1804b1-47494260568mr52916995e9.1.1761215348549; Thu, 23 Oct 2025 03:29:08 -0700 (PDT) Received: from kuoka.. ([178.197.219.123]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-429898cc930sm3816280f8f.33.2025.10.23.03.29.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Oct 2025 03:29:08 -0700 (PDT) From: Krzysztof Kozlowski To: Sebastian Reichel , Dzmitry Sankouski , Krzysztof Kozlowski , Lee Jones , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: stable@vger.kernel.org Subject: [PATCH] power: supply: max77705: Fix potential IRQ chip conflict when probing two devices Date: Thu, 23 Oct 2025 12:29:06 +0200 Message-ID: <20251023102905.71535-2-krzysztof.kozlowski@linaro.org> X-Mailer: git-send-email 2.48.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" MAX77705 charger is most likely always a single device on the board, however nothing stops board designers to have two of them, thus same device driver could probe twice. Or user could manually try to probing second time. Device driver is not ready for that case, because it allocates statically 'struct regmap_irq_chip' as non-const and stores during probe in 'irq_drv_data' member a pointer to per-probe state container ('struct max77705_charger_data'). devm_regmap_add_irq_chip() does not make a copy of 'struct regmap_irq_chip' but stores the pointer. Second probe - either successful or failure - would overwrite the 'irq_drv_data' from previous device probe, so interrupts would be executed in a wrong context. Fixes: a6a494c8e3ce ("power: supply: max77705: Add charger driver for Maxim= 77705") Cc: Signed-off-by: Krzysztof Kozlowski --- Not tested on hardware --- drivers/power/supply/max77705_charger.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/power/supply/max77705_charger.c b/drivers/power/supply= /max77705_charger.c index b1a227bf72e2..1044bf58aeac 100644 --- a/drivers/power/supply/max77705_charger.c +++ b/drivers/power/supply/max77705_charger.c @@ -60,7 +60,7 @@ static const struct regmap_irq max77705_charger_irqs[] = =3D { REGMAP_IRQ_REG_LINE(MAX77705_AICL_I, BITS_PER_BYTE), }; =20 -static struct regmap_irq_chip max77705_charger_irq_chip =3D { +static const struct regmap_irq_chip max77705_charger_irq_chip =3D { .name =3D "max77705-charger", .status_base =3D MAX77705_CHG_REG_INT, .mask_base =3D MAX77705_CHG_REG_INT_MASK, @@ -567,6 +567,7 @@ static int max77705_charger_probe(struct i2c_client *i2= c) { struct power_supply_config pscfg =3D {}; struct max77705_charger_data *chg; + struct regmap_irq_chip *chip_desc; struct device *dev; struct regmap_irq_chip_data *irq_data; int ret; @@ -580,6 +581,13 @@ static int max77705_charger_probe(struct i2c_client *i= 2c) chg->dev =3D dev; i2c_set_clientdata(i2c, chg); =20 + chip_desc =3D devm_kmemdup(dev, &max77705_charger_irq_chip, + sizeof(max77705_charger_irq_chip), + GFP_KERNEL); + if (!chip_desc) + return -ENOMEM; + chip_desc->irq_drv_data =3D chg; + chg->regmap =3D devm_regmap_init_i2c(i2c, &max77705_chg_regmap_config); if (IS_ERR(chg->regmap)) return PTR_ERR(chg->regmap); @@ -599,11 +607,9 @@ static int max77705_charger_probe(struct i2c_client *i= 2c) if (IS_ERR(chg->psy_chg)) return PTR_ERR(chg->psy_chg); =20 - max77705_charger_irq_chip.irq_drv_data =3D chg; ret =3D devm_regmap_add_irq_chip(chg->dev, chg->regmap, i2c->irq, IRQF_ONESHOT, 0, - &max77705_charger_irq_chip, - &irq_data); + chip_desc, &irq_data); if (ret) return dev_err_probe(dev, ret, "failed to add irq chip\n"); =20 --=20 2.48.1