stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 6.1] HID: mcp2221: Set driver data before I2C adapter add
       [not found] <20250716195316.176786-1-sumanth.gavini.ref@yahoo.com>
@ 2025-07-16 19:53 ` Sumanth Gavini
  2025-07-16 20:34   ` kernel test robot
  2025-07-30  2:42   ` [PATCH " Sasha Levin
  0 siblings, 2 replies; 6+ messages in thread
From: Sumanth Gavini @ 2025-07-16 19:53 UTC (permalink / raw)
  To: skhan, david.hunter.linux, gupt21, jikos, benjamin.tissoires
  Cc: Sumanth Gavini, stable, linux-i2c, linux-input, linux-kernel,
	Hamish Martin, Jiri Kosina

The process of adding an I2C adapter can invoke I2C accesses on that new
adapter (see i2c_detect()).

Ensure we have set the adapter's driver data to avoid null pointer
dereferences in the xfer functions during the adapter add.

This has been noted in the past and the same fix proposed but not
completed. See:
https://lore.kernel.org/lkml/ef597e73-ed71-168e-52af-0d19b03734ac@vigem.de/

Signed-off-by: Hamish Martin <hamish.martin@alliedtelesis.co.nz>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Signed-off-by: Sumanth Gavini <sumanth.gavini@yahoo.com>
---
 drivers/hid/hid-mcp2221.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/hid/hid-mcp2221.c b/drivers/hid/hid-mcp2221.c
index de52e9f7bb8c..9973545c1c4b 100644
--- a/drivers/hid/hid-mcp2221.c
+++ b/drivers/hid/hid-mcp2221.c
@@ -873,12 +873,12 @@ static int mcp2221_probe(struct hid_device *hdev,
 			"MCP2221 usb-i2c bridge on hidraw%d",
 			((struct hidraw *)hdev->hidraw)->minor);
 
+	i2c_set_adapdata(&mcp->adapter, mcp);
 	ret = i2c_add_adapter(&mcp->adapter);
 	if (ret) {
 		hid_err(hdev, "can't add usb-i2c adapter: %d\n", ret);
 		goto err_i2c;
 	}
-	i2c_set_adapdata(&mcp->adapter, mcp);
 
 	/* Setup GPIO chip */
 	mcp->gc = devm_kzalloc(&hdev->dev, sizeof(*mcp->gc), GFP_KERNEL);
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 6.1] HID: mcp2221: Set driver data before I2C adapter add
  2025-07-16 19:53 ` [PATCH 6.1] HID: mcp2221: Set driver data before I2C adapter add Sumanth Gavini
@ 2025-07-16 20:34   ` kernel test robot
  2025-07-17  0:01     ` [PATCH V2 " Sumanth Gavini
  2025-07-30  2:42   ` [PATCH " Sasha Levin
  1 sibling, 1 reply; 6+ messages in thread
From: kernel test robot @ 2025-07-16 20:34 UTC (permalink / raw)
  To: Sumanth Gavini; +Cc: stable, oe-kbuild-all

Hi,

Thanks for your patch.

FYI: kernel test robot notices the stable kernel rule is not satisfied.

The check is based on https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html#option-3

Rule: The upstream commit ID must be specified with a separate line above the commit text.
Subject: [PATCH 6.1] HID: mcp2221: Set driver data before I2C adapter add
Link: https://lore.kernel.org/stable/20250716195316.176786-1-sumanth.gavini%40yahoo.com

Please ignore this mail if the patch is not relevant for upstream.

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki




^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH V2 6.1] HID: mcp2221: Set driver data before I2C adapter add
  2025-07-16 20:34   ` kernel test robot
@ 2025-07-17  0:01     ` Sumanth Gavini
  2025-07-18  1:34       ` Sasha Levin
  0 siblings, 1 reply; 6+ messages in thread
From: Sumanth Gavini @ 2025-07-17  0:01 UTC (permalink / raw)
  To: lkp, skhan, david.hunter.linux, gupt21, jikos, benjamin.tissoires
  Cc: Sumanth Gavini, stable, linux-i2c, linux-input, linux-kernel,
	oe-kbuild-all, Hamish Martin, Jiri Kosina

commit f1228f4d4254dfad837f1a1e4c69930417798047 upstream.

The process of adding an I2C adapter can invoke I2C accesses on that new
adapter (see i2c_detect()).

Ensure we have set the adapter's driver data to avoid null pointer
dereferences in the xfer functions during the adapter add.

This has been noted in the past and the same fix proposed but not
completed. See:
https://lore.kernel.org/lkml/ef597e73-ed71-168e-52af-0d19b03734ac@vigem.de/

Signed-off-by: Hamish Martin <hamish.martin@alliedtelesis.co.nz>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Signed-off-by: Sumanth Gavini <sumanth.gavini@yahoo.com>
---
changes in v2:
- No code changes
- Link to v1:https://lore.kernel.org/stable/20250716195316.176786-1-sumanth.gavini@yahoo.com/
- Updated the upstream commit ID in the log
---
 drivers/hid/hid-mcp2221.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/hid/hid-mcp2221.c b/drivers/hid/hid-mcp2221.c
index de52e9f7bb8c..9973545c1c4b 100644
--- a/drivers/hid/hid-mcp2221.c
+++ b/drivers/hid/hid-mcp2221.c
@@ -873,12 +873,12 @@ static int mcp2221_probe(struct hid_device *hdev,
 			"MCP2221 usb-i2c bridge on hidraw%d",
 			((struct hidraw *)hdev->hidraw)->minor);
 
+	i2c_set_adapdata(&mcp->adapter, mcp);
 	ret = i2c_add_adapter(&mcp->adapter);
 	if (ret) {
 		hid_err(hdev, "can't add usb-i2c adapter: %d\n", ret);
 		goto err_i2c;
 	}
-	i2c_set_adapdata(&mcp->adapter, mcp);
 
 	/* Setup GPIO chip */
 	mcp->gc = devm_kzalloc(&hdev->dev, sizeof(*mcp->gc), GFP_KERNEL);
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH V2 6.1] HID: mcp2221: Set driver data before I2C adapter add
  2025-07-17  0:01     ` [PATCH V2 " Sumanth Gavini
@ 2025-07-18  1:34       ` Sasha Levin
  2025-07-18  2:36         ` [PATCH v3 " Sumanth Gavini
  0 siblings, 1 reply; 6+ messages in thread
From: Sasha Levin @ 2025-07-18  1:34 UTC (permalink / raw)
  To: stable, sumanth.gavini; +Cc: Sasha Levin

[ Sasha's backport helper bot ]

Hi,

Summary of potential issues:
❌ Patch application failures detected
⚠️ Provided upstream commit SHA1 does not match found commit

The claimed upstream commit SHA1 (f1228f4d4254dfad837f1a1e4c69930417798047) was not found.
However, I found a matching commit: f2d4a5834638bbc967371b9168c0b481519f7c5e

WARNING: Author mismatch between patch and found commit:
Backport author: Sumanth Gavini <sumanth.gavini@yahoo.com>
Commit author: Hamish Martin <hamish.martin@alliedtelesis.co.nz>

Status in newer kernel trees:
6.15.y | Present (exact SHA1)
6.12.y | Present (exact SHA1)
6.6.y | Present (different SHA1: 2afe67cfe8f1)

Note: Could not generate a diff with upstream commit:
---
Note: Could not generate diff - patch failed to apply for comparison
---

Results of testing on various branches:

| Branch                    | Patch Apply | Build Test |
|---------------------------|-------------|------------|
| origin/linux-6.1.y        | Failed      | N/A        |

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v3 6.1] HID: mcp2221: Set driver data before I2C adapter add
  2025-07-18  1:34       ` Sasha Levin
@ 2025-07-18  2:36         ` Sumanth Gavini
  0 siblings, 0 replies; 6+ messages in thread
From: Sumanth Gavini @ 2025-07-18  2:36 UTC (permalink / raw)
  To: lkp, gupt21, jikos, benjamin.tissoires, sashal
  Cc: Sumanth Gavini, skhan, david.hunter.linux, stable, linux-i2c,
	linux-input, linux-kernel, oe-kbuild-all, Hamish Martin,
	Jiri Kosina

commit f2d4a5834638bbc967371b9168c0b481519f7c5e upstream.

The process of adding an I2C adapter can invoke I2C accesses on that new
adapter (see i2c_detect()).

Ensure we have set the adapter's driver data to avoid null pointer
dereferences in the xfer functions during the adapter add.

This has been noted in the past and the same fix proposed but not
completed. See:
https://lore.kernel.org/lkml/ef597e73-ed71-168e-52af-0d19b03734ac@vigem.de/

Signed-off-by: Hamish Martin <hamish.martin@alliedtelesis.co.nz>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Signed-off-by: Sumanth Gavini <sumanth.gavini@yahoo.com>
---
changes in v3:
- No code changes
- Corrected the upstream commit ID
changes in v2:
- No code changes
- Link to v1:https://lore.kernel.org/stable/20250716195316.176786-1-sumanth.gavini@yahoo.com/
- Updated the upstream commit ID in the log
---
 drivers/hid/hid-mcp2221.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/hid/hid-mcp2221.c b/drivers/hid/hid-mcp2221.c
index de52e9f7bb8c..9973545c1c4b 100644
--- a/drivers/hid/hid-mcp2221.c
+++ b/drivers/hid/hid-mcp2221.c
@@ -873,12 +873,12 @@ static int mcp2221_probe(struct hid_device *hdev,
 			"MCP2221 usb-i2c bridge on hidraw%d",
 			((struct hidraw *)hdev->hidraw)->minor);
 
+	i2c_set_adapdata(&mcp->adapter, mcp);
 	ret = i2c_add_adapter(&mcp->adapter);
 	if (ret) {
 		hid_err(hdev, "can't add usb-i2c adapter: %d\n", ret);
 		goto err_i2c;
 	}
-	i2c_set_adapdata(&mcp->adapter, mcp);
 
 	/* Setup GPIO chip */
 	mcp->gc = devm_kzalloc(&hdev->dev, sizeof(*mcp->gc), GFP_KERNEL);
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 6.1] HID: mcp2221: Set driver data before I2C adapter add
  2025-07-16 19:53 ` [PATCH 6.1] HID: mcp2221: Set driver data before I2C adapter add Sumanth Gavini
  2025-07-16 20:34   ` kernel test robot
@ 2025-07-30  2:42   ` Sasha Levin
  1 sibling, 0 replies; 6+ messages in thread
From: Sasha Levin @ 2025-07-30  2:42 UTC (permalink / raw)
  To: stable, sumanth.gavini; +Cc: Sasha Levin

[ Sasha's backport helper bot ]

Hi,

Summary of potential issues:
⚠️ Found matching upstream commit but patch is missing proper reference to it

Found matching upstream commit: f2d4a5834638bbc967371b9168c0b481519f7c5e

WARNING: Author mismatch between patch and found commit:
Backport author: Sumanth Gavini<sumanth.gavini@yahoo.com>
Commit author: Hamish Martin<hamish.martin@alliedtelesis.co.nz>

Status in newer kernel trees:
6.15.y | Present (exact SHA1)
6.12.y | Present (exact SHA1)
6.6.y | Present (different SHA1: 2afe67cfe8f1)

Note: The patch differs from the upstream commit:
---
1:  f2d4a5834638b < -:  ------------- HID: mcp2221: Set driver data before I2C adapter add
-:  ------------- > 1:  f2198ea7eb3e7 Linux 6.1.145
---

Results of testing on various branches:

| Branch                    | Patch Apply | Build Test |
|---------------------------|-------------|------------|
| stable/linux-6.1.y        |  Success    |  Success   |

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-07-30  2:42 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20250716195316.176786-1-sumanth.gavini.ref@yahoo.com>
2025-07-16 19:53 ` [PATCH 6.1] HID: mcp2221: Set driver data before I2C adapter add Sumanth Gavini
2025-07-16 20:34   ` kernel test robot
2025-07-17  0:01     ` [PATCH V2 " Sumanth Gavini
2025-07-18  1:34       ` Sasha Levin
2025-07-18  2:36         ` [PATCH v3 " Sumanth Gavini
2025-07-30  2:42   ` [PATCH " Sasha Levin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).