Re: [PATCH v1 2/4] spi: Support suppress_override_attrs flag

From: Danilo Krummrich

Date: Fri May 08 2026 - 11:32:57 EST


On Fri May 8, 2026 at 11:42 AM CEST, Andy Shevchenko wrote:
> diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
> index 5f57de24b9f7..40e738f8cbb7 100644
> --- a/drivers/spi/spi.c
> +++ b/drivers/spi/spi.c
> @@ -214,8 +214,19 @@ static struct attribute *spi_dev_attrs[] = {
> NULL,
> };
>
> +static umode_t spi_dev_attr_is_visible(struct kobject *kobj, struct attribute *attr, int i)
> +{
> + struct device *dev = kobj_to_dev(kobj);
> +
> + if (attr == &dev_attr_driver_override.attr)
> + return dev->driver->suppress_override_attrs ? 0 : attr->mode;

This should have the same design problem as described in [1].

Also, wouldn't this oops the kernel right away as dev->driver should be NULL?
How did you test this?

[1] https://lore.kernel.org/driver-core/DIDE94YBOOP3.KM9I6J4JIJIY@xxxxxxxxxx/

> +
> + return attr->mode;
> +}
> +
> static const struct attribute_group spi_dev_group = {
> .attrs = spi_dev_attrs,
> + .is_visible = spi_dev_attr_is_visible,
> };
>
> static struct attribute *spi_device_statistics_attrs[] = {
> --
> 2.50.1