Message ID | 20200429104234.18910-1-tomi.valkeinen@ti.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [1/3] drm/tilcdc: fix leak & null ref in panel_connector_get_modes | expand |
On Wed, Apr 29, 2020 at 01:42:32PM +0300, Tomi Valkeinen wrote: > If videomode_from_timings() returns true, the mode allocated with > drm_mode_create will be leaked. > > Also, the return value of drm_mode_create() is never checked, and thus > could cause NULL deref. > > Fix these two issues. > > Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com> One nit Acked-by: Sam Ravnborg <sam@ravnborg.org> > --- > drivers/gpu/drm/tilcdc/tilcdc_panel.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/tilcdc/tilcdc_panel.c b/drivers/gpu/drm/tilcdc/tilcdc_panel.c > index 5584e656b857..f66e2f2a1a35 100644 > --- a/drivers/gpu/drm/tilcdc/tilcdc_panel.c > +++ b/drivers/gpu/drm/tilcdc/tilcdc_panel.c > @@ -143,12 +143,16 @@ static int panel_connector_get_modes(struct drm_connector *connector) > int i; > > for (i = 0; i < timings->num_timings; i++) { > - struct drm_display_mode *mode = drm_mode_create(dev); > + struct drm_display_mode *mode; > struct videomode vm; > > if (videomode_from_timings(timings, &vm, i)) > break; > > + mode = drm_mode_create(dev); extra space ^ > + if (!mode) > + break; > + > drm_display_mode_from_videomode(&vm, mode); > > mode->type = DRM_MODE_TYPE_DRIVER; > -- > Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. > Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki > > _______________________________________________ > dri-devel mailing list > dri-devel@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/dri-devel
On 29/04/2020 13:42, Tomi Valkeinen wrote: > If videomode_from_timings() returns true, the mode allocated with > drm_mode_create will be leaked. > > Also, the return value of drm_mode_create() is never checked, and thus > could cause NULL deref. > > Fix these two issues. > > Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com> Reviewed-by: Jyri Sarha <jsarha@ti.com> > --- > drivers/gpu/drm/tilcdc/tilcdc_panel.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/tilcdc/tilcdc_panel.c b/drivers/gpu/drm/tilcdc/tilcdc_panel.c > index 5584e656b857..f66e2f2a1a35 100644 > --- a/drivers/gpu/drm/tilcdc/tilcdc_panel.c > +++ b/drivers/gpu/drm/tilcdc/tilcdc_panel.c > @@ -143,12 +143,16 @@ static int panel_connector_get_modes(struct drm_connector *connector) > int i; > > for (i = 0; i < timings->num_timings; i++) { > - struct drm_display_mode *mode = drm_mode_create(dev); > + struct drm_display_mode *mode; > struct videomode vm; > > if (videomode_from_timings(timings, &vm, i)) > break; > > + mode = drm_mode_create(dev); > + if (!mode) > + break; > + > drm_display_mode_from_videomode(&vm, mode); > > mode->type = DRM_MODE_TYPE_DRIVER; >
On 06/05/2020 22:02, Sam Ravnborg wrote: > On Wed, Apr 29, 2020 at 01:42:32PM +0300, Tomi Valkeinen wrote: >> If videomode_from_timings() returns true, the mode allocated with >> drm_mode_create will be leaked. >> >> Also, the return value of drm_mode_create() is never checked, and thus >> could cause NULL deref. >> >> Fix these two issues. >> >> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com> > One nit > Acked-by: Sam Ravnborg <sam@ravnborg.org> >> --- >> drivers/gpu/drm/tilcdc/tilcdc_panel.c | 6 +++++- >> 1 file changed, 5 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/gpu/drm/tilcdc/tilcdc_panel.c b/drivers/gpu/drm/tilcdc/tilcdc_panel.c >> index 5584e656b857..f66e2f2a1a35 100644 >> --- a/drivers/gpu/drm/tilcdc/tilcdc_panel.c >> +++ b/drivers/gpu/drm/tilcdc/tilcdc_panel.c >> @@ -143,12 +143,16 @@ static int panel_connector_get_modes(struct drm_connector *connector) >> int i; >> >> for (i = 0; i < timings->num_timings; i++) { >> - struct drm_display_mode *mode = drm_mode_create(dev); >> + struct drm_display_mode *mode; >> struct videomode vm; >> >> if (videomode_from_timings(timings, &vm, i)) >> break; >> >> + mode = drm_mode_create(dev); > extra space ^ Thanks! Fixed this. Tomi
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_panel.c b/drivers/gpu/drm/tilcdc/tilcdc_panel.c index 5584e656b857..f66e2f2a1a35 100644 --- a/drivers/gpu/drm/tilcdc/tilcdc_panel.c +++ b/drivers/gpu/drm/tilcdc/tilcdc_panel.c @@ -143,12 +143,16 @@ static int panel_connector_get_modes(struct drm_connector *connector) int i; for (i = 0; i < timings->num_timings; i++) { - struct drm_display_mode *mode = drm_mode_create(dev); + struct drm_display_mode *mode; struct videomode vm; if (videomode_from_timings(timings, &vm, i)) break; + mode = drm_mode_create(dev); + if (!mode) + break; + drm_display_mode_from_videomode(&vm, mode); mode->type = DRM_MODE_TYPE_DRIVER;
If videomode_from_timings() returns true, the mode allocated with drm_mode_create will be leaked. Also, the return value of drm_mode_create() is never checked, and thus could cause NULL deref. Fix these two issues. Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com> --- drivers/gpu/drm/tilcdc/tilcdc_panel.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)