From nobody Mon Feb 9 16:13:44 2026 Received: from mail-wr1-f42.google.com (mail-wr1-f42.google.com [209.85.221.42]) (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 9666D2D5944 for ; Thu, 23 Oct 2025 10:19:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761214785; cv=none; b=ZJD8M9VSHx8jqMG5ocZF34qT16S5mObTtSEALdDsLAnFxuszJp2GjHnqF0JM27eaG+lpyhHhI6LlUh2A/1ziprAB8Tp9YG2+D/iUO3g/ggthzndHfPYZe1dESobBV49Aj5X/MsiMB/qIDi4n0kkx+ACROrnhvaxocHx1uBbEwgs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761214785; c=relaxed/simple; bh=sP1yFN5X69EjHA1XrQLO6NIRH09PVVmY0gD8350XCKU=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=ahmh7hHwfEhx9DZTnzOI2TPNL4gHWgcRh7B7jr451GK/Cy0muFy/BkGJLMo6YjBA9x0xKcvY5LqN5AqAT369AIflKAkeD5GOOEL0iy8rTc+lScBUmIPQqZ4Vyhyw5pYtDMvsZKogh+ITj3NmHpT4XISilMC4NwbUC1W9uzumsiY= 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=VNax37lN; arc=none smtp.client-ip=209.85.221.42 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="VNax37lN" Received: by mail-wr1-f42.google.com with SMTP id ffacd0b85a97d-426ff579fbeso105749f8f.0 for ; Thu, 23 Oct 2025 03:19:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1761214782; x=1761819582; 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=YHLKzDlOLcS1osErm5kDOBwxCW+aeEx4uEbgTKleyko=; b=VNax37lNKW8+UFKTUjmxnZDf5U5C1pWp9yjAH6XcSkGmzGEaKPlHH0Q+x40S5RCQHa 7n65aGv3SUQCG/zIKhJykbTZnnIevX1ulSQJq6co1OfBJ3wITO8/LXVdMBiuTs5pGZ4i JyTO5eE3daSf9/jk0GJ1oamy726Io9QE+44KkE46d5ggTJeGC2FNjn0PJbTgdHFe7siZ CCieXtblN9r2nVBKyhaIl0APRfFH+8gSSyvXaPGJ5aQhl5dDqY3Z9SoLcagcBMvB39CT AGytT8XsgoMaHnthJtRqg42pmPthKIC9qsHMOqmHRcf5gxlFchVoIUMGHKvE+E9ao3+c kvZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761214782; x=1761819582; 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=YHLKzDlOLcS1osErm5kDOBwxCW+aeEx4uEbgTKleyko=; b=sViJc0a4uHMJtQufMOAE/XELaLbQ02CtW54oIt/nU0InPbcLAS0L2+xW/oPzSvBvmr ljvwFxtbDe+pHTo2GdLhpgg2XgxAKKfQmX/cxN0LhTvdQn4LBPhxxFbULc0NM8jWGZTg awCDjwDc4Xb+ny7FyIPi2lUXKjyMqkKxAmwBHzT0VSzIJvPNJXxNMTzWnHoUGXr7R78m nFoOVqzExc9H/s9zKVAn+Xt2Elxssy7a0ixe/2qOBvQjsEGEDCIyICFfz6cLIqs24zor CPiWf+KdtLMo7E/x69edAb0/kjB2pjpIiJm7egqFxTwLng+Qvbjdo/g9MyzxaURvKgV5 CDwA== X-Forwarded-Encrypted: i=1; AJvYcCWhPJcW8KUtUcZU3eG8amtxPEQeDXaeggnYx6tt4mHY8hOepUNM/8LB//sckDR1wvJkOK3kXfUIvsW6UH8=@vger.kernel.org X-Gm-Message-State: AOJu0YyeUXwbs0ctY/MjjWsAC24VUt3fHVCKsVVfk9WXL1C0rpjxV9eq waMVV8oJcp95+aCHLmZvNcRGo8ZhE2O1Zqqp+NaFKRp/cZRkfm38m2KVkB+TcSubcYNMBTjyitU 5JSQ3 X-Gm-Gg: ASbGncvgnm9aYz6XAjnqAqNmFgOR5QbHnX70DTmdDofcEileyZRLn+JujUGWwekM514 SA1GJs1XXnLJVeoBZ61rRQE5ivkgXGKvQGdYv4uWpFqwBJAKI+tt8znXyDwmXuFglXRGHePD6uT 46jNJ2ndKmofRpWDOk+kR6er/ZcyQwzp6x5A7CvziI280lG2jYpcYJI8brUzixAwkqHJqBwgZeE KKHYl7Z0We2JNjZ4typqq6Ir4FksUTv76CSw3vLCpquwyJ7FVDdtAvKg1fOpeG84TadmgE4vuAJ 9YdHAOfc0c7K5sWiXmN3fLqw0cBKJg2jYAVsMQwKCYNDZVh3YysWmjjUrF1q7d9c/3wukvpNNtK Yt75DnTui9XBu9ZxChPBBYEMPSGZ01yFb7jEkjvCnotrBrBYl5HesPLl1SjYFVr1gmwF9ircB3c yf8lbJiAssVBJWtyU0PWELWw== X-Google-Smtp-Source: AGHT+IHj7IggOZbvGodn+nW38DF7QGidxY4FbIRHzT1uITsjCrIDo/bUdySa+7xP5mlr//VmMJpJdA== X-Received: by 2002:a05:6000:1863:b0:3fc:854:8b84 with SMTP id ffacd0b85a97d-4284e54a7fbmr3485801f8f.3.1761214781926; Thu, 23 Oct 2025 03:19:41 -0700 (PDT) Received: from kuoka.. ([178.197.219.123]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-429897f57efsm3149173f8f.18.2025.10.23.03.19.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Oct 2025 03:19:41 -0700 (PDT) From: Krzysztof Kozlowski To: Lee Jones , Laxman Dewangan , linux-kernel@vger.kernel.org Cc: Krzysztof Kozlowski , stable@vger.kernel.org Subject: [RFT PATCH] mfd: max77620: Fix potential IRQ chip conflict when probing two devices Date: Thu, 23 Oct 2025 12:19:40 +0200 Message-ID: <20251023101939.67991-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" MAX77620 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 max77620_chip'). devm_regmap_add_irq_chip() does not make a copy of 'struct regmap_irq_chip' but store 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: 3df140d11c6d ("mfd: max77620: Mask/unmask interrupt before/after ser= vicing it") Cc: Signed-off-by: Krzysztof Kozlowski --- Not tested on hardware --- drivers/mfd/max77620.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/drivers/mfd/max77620.c b/drivers/mfd/max77620.c index 21d2ab3db254..3af2974b3023 100644 --- a/drivers/mfd/max77620.c +++ b/drivers/mfd/max77620.c @@ -254,7 +254,7 @@ static int max77620_irq_global_unmask(void *irq_drv_dat= a) return ret; } =20 -static struct regmap_irq_chip max77620_top_irq_chip =3D { +static const struct regmap_irq_chip max77620_top_irq_chip =3D { .name =3D "max77620-top", .irqs =3D max77620_top_irqs, .num_irqs =3D ARRAY_SIZE(max77620_top_irqs), @@ -498,6 +498,7 @@ static int max77620_probe(struct i2c_client *client) const struct i2c_device_id *id =3D i2c_client_get_device_id(client); const struct regmap_config *rmap_config; struct max77620_chip *chip; + struct regmap_irq_chip *chip_desc; const struct mfd_cell *mfd_cells; int n_mfd_cells; bool pm_off; @@ -508,6 +509,14 @@ static int max77620_probe(struct i2c_client *client) return -ENOMEM; =20 i2c_set_clientdata(client, chip); + + chip_desc =3D devm_kmemdup(&client->dev, &max77620_top_irq_chip, + sizeof(max77620_top_irq_chip), + GFP_KERNEL); + if (!chip_desc) + return -ENOMEM; + chip_desc->irq_drv_data =3D chip; + chip->dev =3D &client->dev; chip->chip_irq =3D client->irq; chip->chip_id =3D (enum max77620_chip_id)id->driver_data; @@ -544,11 +553,9 @@ static int max77620_probe(struct i2c_client *client) if (ret < 0) return ret; =20 - max77620_top_irq_chip.irq_drv_data =3D chip; ret =3D devm_regmap_add_irq_chip(chip->dev, chip->rmap, client->irq, IRQF_ONESHOT | IRQF_SHARED, 0, - &max77620_top_irq_chip, - &chip->top_irq_data); + chip_desc, &chip->top_irq_data); if (ret < 0) { dev_err(chip->dev, "Failed to add regmap irq: %d\n", ret); return ret; --=20 2.48.1