Message ID | 20241025073408.27481-3-zhangzekun11@huawei.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | drm: Add a check to prevent NULL pointer dereference | expand |
On 25/10/2024 09:34, Zhang Zekun wrote: > drm_mode_duplicate() could return NULL due to lack of memory, > which will then call NULL pointer dereference. Add a check to > prevent it. > > Fixes: 0ef94554dc40 ("drm/panel: himax-hx83102: Break out as separate driver") > Signed-off-by: Zhang Zekun <zhangzekun11@huawei.com> > --- > drivers/gpu/drm/panel/panel-himax-hx83102.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/drivers/gpu/drm/panel/panel-himax-hx83102.c b/drivers/gpu/drm/panel/panel-himax-hx83102.c > index 8b48bba18131..3644a7544b93 100644 > --- a/drivers/gpu/drm/panel/panel-himax-hx83102.c > +++ b/drivers/gpu/drm/panel/panel-himax-hx83102.c > @@ -565,6 +565,8 @@ static int hx83102_get_modes(struct drm_panel *panel, > struct drm_display_mode *mode; > > mode = drm_mode_duplicate(connector->dev, m); > + if (!mode) > + return -ENOMEM; > > mode->type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED; > drm_mode_set_name(mode); Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>
diff --git a/drivers/gpu/drm/panel/panel-himax-hx83102.c b/drivers/gpu/drm/panel/panel-himax-hx83102.c index 8b48bba18131..3644a7544b93 100644 --- a/drivers/gpu/drm/panel/panel-himax-hx83102.c +++ b/drivers/gpu/drm/panel/panel-himax-hx83102.c @@ -565,6 +565,8 @@ static int hx83102_get_modes(struct drm_panel *panel, struct drm_display_mode *mode; mode = drm_mode_duplicate(connector->dev, m); + if (!mode) + return -ENOMEM; mode->type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED; drm_mode_set_name(mode);
drm_mode_duplicate() could return NULL due to lack of memory, which will then call NULL pointer dereference. Add a check to prevent it. Fixes: 0ef94554dc40 ("drm/panel: himax-hx83102: Break out as separate driver") Signed-off-by: Zhang Zekun <zhangzekun11@huawei.com> --- drivers/gpu/drm/panel/panel-himax-hx83102.c | 2 ++ 1 file changed, 2 insertions(+)