mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "jiale yao" <19888972804@163.com>
To: "Biju Das" <biju.das.jz@bp.renesas.com>
Cc: "Linus Walleij" <linusw@kernel.org>,
	"Andy Shevchenko" <andriy.shevchenko@linux.intel.com>,
	"linux-gpio@vger.kernel.org" <linux-gpio@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re:Re:RE: [PATCH] pinctrl: mcp23s08: reject devices without match data
Date: Sat, 26 Sep 2026 18:28:40 +0800 (CST)	[thread overview]
Message-ID: <1358a442.197f.1a0dd4289ef.Coremail.19888972804@163.com> (raw)
In-Reply-To: <34472b57.1961.1a0dd3dff12.Coremail.19888972804@163.com>

At 2026-09-26 18:23:42, "jiale yao" <19888972804@163.com> wrote:
>Hi Biju,
>
>At 2026-09-26 18:07:14, "Biju Das" <biju.das.jz@bp.renesas.com> wrote:
>>Hi,
>>
>>> -----Original Message-----
>>> From: Jiale Yao <yaojiale02@163.com>
>>> Sent: 25 September 2026 14:38
>>> Subject: [PATCH] pinctrl: mcp23s08: reject devices without match data
>>> 
>>> A device bound through driver_override need not match an entry in the driver tables. In that case
>>> spi_get_device_match_data() returns NULL, but mcp23s08_probe() later passes the result to the regmap
>>> setup and dereferences it while setting up each device.
>>
>>I believe this is an invalid use case as the user trying driver_override
>>and the probe returns error. Am I missing anything here?
>
>Yes, my commit message was not clear enough. This patch is intended to fix
>a regression introduced by commit 2e44555b05c0, rather than to make an
>unmatched device probe successfully through driver_override.
>
>Before that commit, missing match data effectively resulted in type 0,
>which fell through to the default switch case and returned -EINVAL.
>Commit 2e44555b05c0 replaced the type value with an info pointer, but the
>SPI path missed the corresponding NULL check before dereferencing
>info->type. The I2C path preserved the previous error handling with an
>explicit NULL check after the same conversion.

Just like.
---
+       info = i2c_get_match_data(client);
+       if (!info)
+               return dev_err_probe(dev, -EINVAL, "invalid device type\n");
---
The return value of spi_get_device_match_data should be check also.

>
>Consequently, an unmatched device bound through driver_override used to
>fail cleanly. It can now cause a NULL pointer dereference when a valid
>spi-present-mask property is present. This patch restores the previous
>failure behavior.
>
>>
>>Can you please prepare a patch that makes the driver probe success by using driver_override
>>Feature? Also please share some logs to see how it works in real device
>>
>>Cheers,
>>Biju
>>
>>> 
>>> Reject devices without match data before reading device properties.
>>> 
>>> Fixes: 2e44555b05c0 ("pinctrl: mcp23s08: Simplify probe()/mcp23s08_spi_regmap_init()")
>>> Signed-off-by: Jiale Yao <yaojiale02@163.com>
>>> ---
>>>  drivers/pinctrl/pinctrl-mcp23s08_spi.c | 2 ++
>>>  1 file changed, 2 insertions(+)
>>> 
>>> diff --git a/drivers/pinctrl/pinctrl-mcp23s08_spi.c b/drivers/pinctrl/pinctrl-mcp23s08_spi.c
>>> index bacebcff67ef..926034fcd512 100644
>>> --- a/drivers/pinctrl/pinctrl-mcp23s08_spi.c
>>> +++ b/drivers/pinctrl/pinctrl-mcp23s08_spi.c
>>> @@ -146,6 +146,8 @@ static int mcp23s08_probe(struct spi_device *spi)
>>>  	u8 v;
>>> 
>>>  	info = spi_get_device_match_data(spi);
>>> +	if (!info)
>>> +		return -ENODATA;
>>> 
>>>  	ret = device_property_read_u8(dev, "microchip,spi-present-mask", &v);
>>>  	if (ret) {
>>> --
>>> 2.34.1
>
>Cheers,
>Jiale
>

  reply	other threads:[~2026-09-26 10:29 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-25 13:38 Jiale Yao
2026-09-26 10:07 ` Biju Das
2026-09-26 10:23   ` jiale yao
2026-09-26 10:28     ` jiale yao [this message]
2026-09-28  6:03     ` Biju Das
2026-09-28  7:24       ` jiale yao
2026-09-28  7:32         ` Biju Das
2026-09-28  7:54           ` jiale yao
2026-09-28  8:05             ` Biju Das

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1358a442.197f.1a0dd4289ef.Coremail.19888972804@163.com \
    --to=19888972804@163.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=biju.das.jz@bp.renesas.com \
    --cc=linusw@kernel.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®