Add logging to have it printed when mode creating fails. As the NULL return has been present here for a long time, it's better to keep it as it is. However, a simple drm_notice() print should be helpful when such fail happens. At the same time, adding drm_notice() to drm_mode_duplicate() allows making use of *dev parameter and at the same time, keeps the further drm_mode_duplicate() references stable.
It's a matter of discussion whether NULL or error code should be returned - the latter might be more elegant and secure, but introducing it would mean breaking internal API (current references). It's a cost which might be considered, if needed. Signed-off-by: Jan Niedziolka <[email protected]> --- drivers/gpu/drm/drm_modes.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/drm_modes.c b/drivers/gpu/drm/drm_modes.c index 049d77e75ddd..fc6d974e3948 100644 --- a/drivers/gpu/drm/drm_modes.c +++ b/drivers/gpu/drm/drm_modes.c @@ -646,8 +646,10 @@ struct drm_display_mode *drm_cvt_mode(struct drm_device *dev, int hdisplay, * return directly */ drm_mode = drm_mode_create(); - if (!drm_mode) + if (!drm_mode) { + drm_notice(dev, "Failed to create a new display mode\n"); return NULL; + } /* the CVT default refresh rate is 60Hz */ if (!vrefresh) @@ -881,8 +883,10 @@ drm_gtf_mode_complex(struct drm_device *dev, int hdisplay, int vdisplay, return NULL; drm_mode = drm_mode_create(); - if (!drm_mode) + if (!drm_mode) { + drm_notice(dev, "Failed to create a new display mode\n"); return NULL; + } /* 1. In order to give correct results, the number of horizontal * pixels requested is first processed to ensure that it is divisible @@ -1458,8 +1462,10 @@ struct drm_display_mode *drm_mode_duplicate(struct drm_device *dev, struct drm_display_mode *nmode; nmode = drm_mode_create(); - if (!nmode) + if (!nmode) { + drm_notice(dev, "Failed to create a new display mode\n"); return NULL; + } drm_mode_copy(nmode, mode); -- 2.43.0
