Several drivers do some sanity checks on the lane number. Checking it is
non-zero will allow to remove such checks.

Additionally, we are about to move to an .attach_new host op which won't
pass a pointer that the host driver can store. This will prevent host
drivers to check for the presence of a device by storing such pointer and
checking whether it is NULL. As a replacement, host drivers will be able to
check the lane number to be non-zero, so ensuring a zero value is never
passed along will make such checks robust.

Signed-off-by: Luca Ceresoli <[email protected]>
---
 drivers/gpu/drm/drm_mipi_dsi.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/drm_mipi_dsi.c b/drivers/gpu/drm/drm_mipi_dsi.c
index 
a00d76443128e4972f939a8c9e26d949d2b30bb9..82d4f9c1de5fbc60f32d0b0baf41e1bd2991ebe4
 100644
--- a/drivers/gpu/drm/drm_mipi_dsi.c
+++ b/drivers/gpu/drm/drm_mipi_dsi.c
@@ -379,6 +379,9 @@ int mipi_dsi_attach(struct mipi_dsi_device *dsi)
        if (!ops || !ops->attach)
                return -ENOSYS;
 
+       if (dsi->lanes < 1)
+               return dev_err_probe(&dsi->dev, -EINVAL, "Incorrect lanes 
number\n");
+
        ret = ops->attach(dsi->host, dsi);
        if (ret)
                return ret;

-- 
2.49.0

Reply via email to