diff mbox series

[v2,2/2] drm: mxsfb: Fix NULL pointer dereference

Message ID 20220202081755.145716-3-alexander.stein@ew.tq-group.com (mailing list archive)
State New, archived
Headers show
Series mxsfb fixes | expand

Commit Message

Alexander Stein Feb. 2, 2022, 8:17 a.m. UTC
mxsfb should not never dereference the NULL pointer which
drm_atomic_get_new_bridge_state is allowed to return.
Assume a fixed format instead.

Fixes: commit b776b0f00f24 ("drm: mxsfb: Use bus_format from the nearest bridge if present")
Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
---
 drivers/gpu/drm/mxsfb/mxsfb_kms.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Marek Vasut Feb. 2, 2022, 8:30 a.m. UTC | #1
On 2/2/22 09:17, Alexander Stein wrote:
> mxsfb should not never dereference the NULL pointer which

... not ever ... but that's really a nitpick.

> drm_atomic_get_new_bridge_state is allowed to return.
> Assume a fixed format instead.
> 
> Fixes: commit b776b0f00f24 ("drm: mxsfb: Use bus_format from the nearest bridge if present")
> Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>

It's perfect otherwise, thanks !
Alexander Stein Feb. 2, 2022, 9 a.m. UTC | #2
Am Mittwoch, 2. Februar 2022, 09:30:38 CET schrieb Marek Vasut:
> On 2/2/22 09:17, Alexander Stein wrote:
> > mxsfb should not never dereference the NULL pointer which
> 
> ... not ever ... but that's really a nitpick.

Doh, I just copied it from my mail...
You want me to send a v2.1? Or will someone fix it when applying?

> > drm_atomic_get_new_bridge_state is allowed to return.
> > Assume a fixed format instead.
> > 
> > Fixes: commit b776b0f00f24 ("drm: mxsfb: Use bus_format from the nearest
> > bridge if present") Signed-off-by: Alexander Stein
> > <alexander.stein@ew.tq-group.com>
> 
> It's perfect otherwise, thanks !

Thanks,
Alexander
Marek Vasut Feb. 2, 2022, 9:03 a.m. UTC | #3
On 2/2/22 10:00, Alexander Stein wrote:
> Am Mittwoch, 2. Februar 2022, 09:30:38 CET schrieb Marek Vasut:
>> On 2/2/22 09:17, Alexander Stein wrote:
>>> mxsfb should not never dereference the NULL pointer which
>>
>> ... not ever ... but that's really a nitpick.
> 
> Doh, I just copied it from my mail...
> You want me to send a v2.1? Or will someone fix it when applying?

I think it can be fixed when applying, no worries.
Marek Vasut Feb. 3, 2022, 8:58 a.m. UTC | #4
On 2/2/22 10:03, Marek Vasut wrote:
> On 2/2/22 10:00, Alexander Stein wrote:
>> Am Mittwoch, 2. Februar 2022, 09:30:38 CET schrieb Marek Vasut:
>>> On 2/2/22 09:17, Alexander Stein wrote:
>>>> mxsfb should not never dereference the NULL pointer which
>>>
>>> ... not ever ... but that's really a nitpick.
>>
>> Doh, I just copied it from my mail...
>> You want me to send a v2.1? Or will someone fix it when applying?
> 
> I think it can be fixed when applying, no worries.

Applied to drm-misc/drm-misc-fixes , thanks.
diff mbox series

Patch

diff --git a/drivers/gpu/drm/mxsfb/mxsfb_kms.c b/drivers/gpu/drm/mxsfb/mxsfb_kms.c
index 0655582ae8ed..4cfb6c001679 100644
--- a/drivers/gpu/drm/mxsfb/mxsfb_kms.c
+++ b/drivers/gpu/drm/mxsfb/mxsfb_kms.c
@@ -361,7 +361,11 @@  static void mxsfb_crtc_atomic_enable(struct drm_crtc *crtc,
 		bridge_state =
 			drm_atomic_get_new_bridge_state(state,
 							mxsfb->bridge);
-		bus_format = bridge_state->input_bus_cfg.format;
+		if (!bridge_state)
+			bus_format = MEDIA_BUS_FMT_FIXED;
+		else
+			bus_format = bridge_state->input_bus_cfg.format;
+
 		if (bus_format == MEDIA_BUS_FMT_FIXED) {
 			dev_warn_once(drm->dev,
 				      "Bridge does not provide bus format, assuming MEDIA_BUS_FMT_RGB888_1X24.\n"