Skip to contentSkip to conversation

drm/amd/display: Trigger bug when allocation fails.

PATCH In review Tom St Denis 4 participants 8 messages Oct 17, 2017 5 messages not in the archive

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amd/display: Trigger bug when allocation fails.

If the allocation fails in amdgpu_dm_connector_funcs_reset() the API cannot continue so trigger a BUG_ON.

---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1 -0
index 58e29a2a5ca6..ac58ba4f10cf 100644
@@ -2722,6 +2722,7 @@ void amdgpu_dm_connector_funcs_reset(struct drm_connector *connector)
 	kfree(state);
 
 	state = kzalloc(sizeof(*state), GFP_KERNEL);
+	BUG_ON(state == NULL);
 
 	if (state) {
 		state->scaling = RMX_OFF;
Signature · 6 lines
2.12.0

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): [email protected]

Reviewed-by
#2 lore raw
Quoted 13 lines · Tom St Denis

If the allocation fails in amdgpu_dm_connector_funcs_reset() the API cannot continue so trigger a BUG_ON.

---
  drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 1 +
  1 file changed, 1 insertion(+)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0 -0
index 58e29a2a5ca6..ac58ba4f10cf 100644

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c void amdgpu_dm_connector_funcs_reset(struct drm_connector *connector) · line 2728

Quoted 7 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1 -0
@@ -2722,6 +2722,7 @@ void amdgpu_dm_connector_funcs_reset(struct drm_connector *connector)
  	kfree(state);
 
  	state = kzalloc(sizeof(*state), GFP_KERNEL);
+	BUG_ON(state == NULL);
 
  	if (state) {
  		state->scaling = RMX_OFF;

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#3 lore raw
In reply to a message not in the archive
Quoted 2 lines · Tom St Denis

If the allocation fails in amdgpu_dm_connector_funcs_reset() the API cannot continue so trigger a BUG_ON.

That seems questionable to be honest. The drm_atomic_helper version of this function ends up setting connector->state = NULL; in this case.

Cheers,
Nicolai

Quoted 19 lines
---
  drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 1 +
  1 file changed, 1 insertion(+)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1 -0
index 58e29a2a5ca6..ac58ba4f10cf 100644
@@ -2722,6 +2722,7 @@ void amdgpu_dm_connector_funcs_reset(struct drm_connector *connector)
  	kfree(state);
 
  	state = kzalloc(sizeof(*state), GFP_KERNEL);
+	BUG_ON(state == NULL);
 
  	if (state) {
  		state->scaling = RMX_OFF;
Signature · 6 lines
Lerne, wie die Welt wirklich ist,
Aber vergiss niemals, wie sie sein sollte.
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): d035e531-09e5-0307-4340-7c96685dc60e-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#5 lore raw
Quoted 6 lines · Nicolai Hähnle
Quoted 2 lines · Tom St Denis

If the allocation fails in amdgpu_dm_connector_funcs_reset() the API cannot continue so trigger a BUG_ON.

That seems questionable to be honest. The drm_atomic_helper version of this function ends up setting connector->state = NULL; in this case.

If we feel this BUG_ON is a priority this patch is

Ultimately it wouldn't be hard to just copy/pase the drm_atomic_helper version, plus the amdgpu_dm specific stuff. That sounds like the more correct approach to me and will keep us from weird behavior should Daniel do another drive-by-refactor in the atomic framework.

Harry

Quoted 9 lines

Cheers,
Nicolai

Quoted 6 lines

---
  drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 1 +

  1 file changed, 1 insertion(+)
Quoted 13 lines

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c void amdgpu_dm_connector_funcs_reset(struct drm_connector *connector) · line 2727

Quoted 11 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1 -0
index 58e29a2a5ca6..ac58ba4f10cf 100644
@@ -2722,6 +2722,7 @@ void amdgpu_dm_connector_funcs_reset(struct drm_connector *connector)
       kfree(state);
         state = kzalloc(sizeof(*state), GFP_KERNEL);
+    BUG_ON(state == NULL);
         if (state) {
           state->scaling = RMX_OFF;
 

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#6 lore raw
In reply to a message not in the archive
Quoted 5 lines · Nicolai Hähnle
Quoted 2 lines · Tom St Denis

If the allocation fails in amdgpu_dm_connector_funcs_reset() the API cannot continue so trigger a BUG_ON.

That seems questionable to be honest. The drm_atomic_helper version of this function ends up setting connector->state = NULL; in this case.

I see it now, it will propagate back to user mode as -ENOMEM, so i guess it's good just set it as NULL.

Thanks,
Andrey

Quoted 10 lines

Cheers,
Nicolai

Quoted 6 lines
---
  drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 1 +
  1 file changed, 1 insertion(+)
Quoted 14 lines

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c void amdgpu_dm_connector_funcs_reset(struct · line 2728

Quoted 12 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1 -0
index 58e29a2a5ca6..ac58ba4f10cf 100644
@@ -2722,6 +2722,7 @@ void amdgpu_dm_connector_funcs_reset(struct 
 drm_connector *connector)
      kfree(state);
        state = kzalloc(sizeof(*state), GFP_KERNEL);
+    BUG_ON(state == NULL);
        if (state) {
          state->scaling = RMX_OFF;
 

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 49649733-17eb-4d9a-a523-340be9a6a0e2-5C7GfCeVMHo@public.gmane.org

#8 lore raw

I'm ok with not pushing my commit and simply adding an else branch that sets the pointer to NULL.

(maybe put a WARN_ON to give context?)

Tom

Quoted 7 lines · Andrey Grodzovsky
Quoted 4 lines · Nicolai Hähnle
Quoted 2 lines · Tom St Denis

If the allocation fails in amdgpu_dm_connector_funcs_reset() the API cannot continue so trigger a BUG_ON.

Quoted 32 lines
Quoted 1 line

That seems questionable to be honest. The drm_atomic_helper version of this function ends up setting connector->state = NULL; in this case.

I see it now, it will propagate back to user mode as -ENOMEM, so i guess it's good just set it as NULL.

Thanks,
Andrey

Quoted 24 lines

Cheers,
Nicolai

Quoted 18 lines

---
  drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 1 +

  1 file changed, 1 insertion(+)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1 -0
index 58e29a2a5ca6..ac58ba4f10cf 100644
@@ -2722,6 +2722,7 @@ void amdgpu_dm_connector_funcs_reset(struct 
 drm_connector *connector)
       kfree(state);
         state = kzalloc(sizeof(*state), GFP_KERNEL);
+    BUG_ON(state == NULL);
         if (state) {
           state->scaling = RMX_OFF;
 

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 13db5809-f805-7289-f901-3d675b24faf5-5C7GfCeVMHo@public.gmane.org

#10 lore raw
Quoted 3 lines · Tom St Denis

I'm ok with not pushing my commit and simply adding an else branch that sets the pointer to NULL.

(maybe put a WARN_ON to give context?)

Seems reasonable to me.
Harry ?

Andrey

Quoted 44 lines

Tom

Quoted 39 lines · Andrey Grodzovsky
Quoted 5 lines · Nicolai Hähnle
Quoted 2 lines · Tom St Denis

If the allocation fails in amdgpu_dm_connector_funcs_reset() the API cannot continue so trigger a BUG_ON.

That seems questionable to be honest. The drm_atomic_helper version of this function ends up setting connector->state = NULL; in this case.

I see it now, it will propagate back to user mode as -ENOMEM, so i guess it's good just set it as NULL.

Thanks,
Andrey

Quoted 24 lines

Cheers,
Nicolai

Quoted 18 lines
---
  drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 1 +
  1 file changed, 1 insertion(+)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1 -0
index 58e29a2a5ca6..ac58ba4f10cf 100644
@@ -2722,6 +2722,7 @@ void amdgpu_dm_connector_funcs_reset(struct 
 drm_connector *connector)
      kfree(state);
        state = kzalloc(sizeof(*state), GFP_KERNEL);
+    BUG_ON(state == NULL);
        if (state) {
          state->scaling = RMX_OFF;
 

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): ef080a5a-f1f2-e386-defd-c5c72fd61d33-5C7GfCeVMHo@public.gmane.org

#12 lore raw
Quoted 10 lines · Andrey Grodzovsky
Quoted 3 lines · Tom St Denis

I'm ok with not pushing my commit and simply adding an else branch that sets the pointer to NULL.

(maybe put a WARN_ON to give context?)

Seems reasonable to me.
Harry ?

Sure.

Harry

Quoted 46 lines

Andrey

Quoted 43 lines

Tom

Quoted 38 lines · Andrey Grodzovsky
Quoted 5 lines · Nicolai Hähnle
Quoted 2 lines · Tom St Denis

If the allocation fails in amdgpu_dm_connector_funcs_reset() the API cannot continue so trigger a BUG_ON.

That seems questionable to be honest. The drm_atomic_helper version of this function ends up setting connector->state = NULL; in this case.

I see it now, it will propagate back to user mode as -ENOMEM, so i guess it's good just set it as NULL.

Thanks,
Andrey

Quoted 23 lines

Cheers,
Nicolai

Quoted 17 lines

---
  drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 1 +

  1 file changed, 1 insertion(+)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1 -0
index 58e29a2a5ca6..ac58ba4f10cf 100644
@@ -2722,6 +2722,7 @@ void amdgpu_dm_connector_funcs_reset(struct drm_connector *connector)
       kfree(state);
         state = kzalloc(sizeof(*state), GFP_KERNEL);
+    BUG_ON(state == NULL);
         if (state) {
           state->scaling = RMX_OFF;
 

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx