Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [High] drm: NULL pointer dereference in mipi_dbi_bus_shutdown() on unbound device --
commit a575546c0815e7093e5a3e166f417f51579ae7fa Author: Svyatoslav Ryhel <[email protected]> drm: Add MIPI DBI bus support for MIPI DBI Type A and B This commit adds a Linux driver model bus and helpers for MIPI DBI Type A and Type B hosts and peripherals. > diff --git a/drivers/gpu/drm/drm_mipi_dbi_bus.c > b/drivers/gpu/drm/drm_mipi_dbi_bus.c > new file mode 100644 > index 0000000000000..0c9b93d72021b > --- /dev/null > +++ b/drivers/gpu/drm/drm_mipi_dbi_bus.c > @@ -0,0 +1,265 @@ [ ... ] > +static void mipi_dbi_bus_shutdown(struct device *dev) > +{ > + struct mipi_dbi_driver *drv = to_mipi_dbi_driver(dev->driver); > + struct mipi_dbi_device *dbidev = to_mipi_dbi_device(dev); > + > + if (drv->shutdown) > + drv->shutdown(dbidev); > +} > + > +static const struct bus_type mipi_dbi_bus_type = { > + .name = "mipi-dbi", > + .match = of_driver_match_device, > + .uevent = of_device_uevent_modalias, > + .probe = mipi_dbi_bus_probe, > + .remove = mipi_dbi_bus_remove, > + .shutdown = mipi_dbi_bus_shutdown, > +}; [Severity: High] Can mipi_dbi_bus_shutdown() cause a NULL pointer dereference when a registered mipi_dbi_device has no bound driver? device_shutdown() invokes dev->bus->shutdown(dev) unconditionally without checking whether dev->driver is set: drivers/base/core.c:device_shutdown() { ... if (dev->bus && dev->bus->shutdown) { if (initcall_debug) dev_info(dev, "shutdown\n"); dev->bus->shutdown(dev); } else if (dev->driver && dev->driver->shutdown) { ... } Because driver is the first member of struct mipi_dbi_driver, to_mipi_dbi_driver(NULL) evaluates to NULL and checking drv->shutdown dereferences NULL during system shutdown if a peripheral driver was not loaded, deferred probing, or was unbound. -- Sashiko AI review ยท https://sashiko.dev/#/patchset/[email protected]?part=1
