Skip to contentSkip to conversation

drm/exynos: vidi: fix a wrong error return

PATCH In review Inki Dae 3 participants 6 messages May 19, 2023 – May 23, 2023 1 message not in the archive

Subsystems (3)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): CGME20230519000408epcas1p4f5d90f588e7250d2d168d2943adef4f7@epcas1p4.samsung.com

Inki Dae

author maintainer
#1 lore raw

PATCH 1/1 drm/exynos: vidi: fix a wrong error return

Fix a wrong error return by dropping an error return.

When vidi driver is remvoed, if ctx->raw_edid isn't same as fake_edid_info then only what we have to is to free ctx->raw_edid so that driver removing can work correctly - it's not an error case.

---
 drivers/gpu/drm/exynos/exynos_drm_vidi.c | 2 --
 1 file changed, 2 deletions(-)
drivers/gpu/drm/exynos/exynos_drm_vidi.c +0 -2
index 4d56c8c799c5..f5e1adfcaa51 100644
@@ -469,8 +469,6 @@ static int vidi_remove(struct platform_device *pdev)
 	if (ctx->raw_edid != (struct edid *)fake_edid_info) {
 		kfree(ctx->raw_edid);
 		ctx->raw_edid = NULL;
-
-		return -EINVAL;
 	}
 
 	component_del(&pdev->dev, &vidi_component_ops);
Signature · 1 line
2.25.1
#2 lore raw

Hi Inki,

Quoted 16 lines · Inki Dae

Fix a wrong error return by dropping an error return.

When vidi driver is remvoed, if ctx->raw_edid isn't same as fake_edid_info then only what we have to is to free ctx->raw_edid so that driver removing can work correctly - it's not an error case.

---
 drivers/gpu/drm/exynos/exynos_drm_vidi.c | 2 --
 1 file changed, 2 deletions(-)
drivers/gpu/drm/exynos/exynos_drm_vidi.c +0 -0
index 4d56c8c799c5..f5e1adfcaa51 100644

drivers/gpu/drm/exynos/exynos_drm_vidi.c static int vidi_remove(struct platform_device *pdev) · line 473

Quoted 5 lines
drivers/gpu/drm/exynos/exynos_drm_vidi.c +0 -2
@@ -469,8 +469,6 @@ static int vidi_remove(struct platform_device *pdev)
 	if (ctx->raw_edid != (struct edid *)fake_edid_info) {
 		kfree(ctx->raw_edid);
 		ctx->raw_edid = NULL;
-
-		return -EINVAL;

It doesn't look right to me, I think the correct patch should be:

- if (ctx->raw_edid != (struct edid *)fake_edid_info) {
- kfree(ctx->raw_edid);
- ctx->raw_edid = NULL;
-
- return -EINVAL;
- }
-
+ ctx->raw_edid = NULL;

because "ctx->raw_edid" points to a non allocated memory in the .data segment and you cannot free it.

A follow-up cleanup should be to remove the "const" from fake_edid_info because you are assigning its address to pointers (raw_edid), so that what's the point for having it const? You are just fooling the compiler :)

Andi

Quoted 5 lines
drivers/gpu/drm/exynos/exynos_drm_vidi.c +0 -0
 	}
 
 	component_del(&pdev->dev, &vidi_component_ops);
Signature · 1 line
2.25.1
Reviewed-by
#3 lore raw

Hi Inki,

Quoted 36 lines · Andi Shyti

Hi Inki,

Quoted 16 lines · Inki Dae

Fix a wrong error return by dropping an error return.

When vidi driver is remvoed, if ctx->raw_edid isn't same as fake_edid_info then only what we have to is to free ctx->raw_edid so that driver removing can work correctly - it's not an error case.

---
 drivers/gpu/drm/exynos/exynos_drm_vidi.c | 2 --
 1 file changed, 2 deletions(-)
drivers/gpu/drm/exynos/exynos_drm_vidi.c +0 -0
index 4d56c8c799c5..f5e1adfcaa51 100644

drivers/gpu/drm/exynos/exynos_drm_vidi.c static int vidi_remove(struct platform_device *pdev) · line 473

Quoted 5 lines
drivers/gpu/drm/exynos/exynos_drm_vidi.c +0 -2
@@ -469,8 +469,6 @@ static int vidi_remove(struct platform_device *pdev)
 	if (ctx->raw_edid != (struct edid *)fake_edid_info) {
 		kfree(ctx->raw_edid);
 		ctx->raw_edid = NULL;
-
-		return -EINVAL;

It doesn't look right to me, I think the correct patch should be:

(quoted diff) +1 -7
-       if (ctx->raw_edid != (struct edid *)fake_edid_info) {
-               kfree(ctx->raw_edid);
-               ctx->raw_edid = NULL;
-
-               return -EINVAL;
-       }
-
+       ctx->raw_edid = NULL;
Quoted 7 lines

because "ctx->raw_edid" points to a non allocated memory in the .data segment and you cannot free it.

A follow-up cleanup should be to remove the "const" from fake_edid_info because you are assigning its address to pointers (raw_edid), so that what's the point for having it const? You are just fooling the compiler :)

please ignore, this is what happens when reading patches at 2.26am, that a "!=" becomes "==". The patch is correct, still some cleanups is needed here, though.

Andi

PS I was actually sleeping and this woke me up :)

Quoted 7 lines

Andi

Quoted 5 lines
drivers/gpu/drm/exynos/exynos_drm_vidi.c +0 -0
 	}
 
 	component_del(&pdev->dev, &vidi_component_ops);
Signature · 1 line
2.25.1
author maintainer
#4 lore raw
In reply to Andi Shyti

Hi Andi, :)

Quoted 45 lines

-----Original Message-----
From: Andi Shyti <[email protected]>
Sent: Friday, May 19, 2023 9:27 AM
To: Inki Dae <[email protected]>
Cc: [email protected]; [email protected]; Andi Shyti <[email protected]>
Subject: Re: [PATCH] drm/exynos: vidi: fix a wrong error return

Hi Inki,

Quoted 6 lines · Inki Dae

Fix a wrong error return by dropping an error return.

When vidi driver is remvoed, if ctx->raw_edid isn't same as fake_edid_info then only what we have to is to free ctx->raw_edid so that driver removing can work correctly - it's not an error case.

Review

Quoted 6 lines
---
 drivers/gpu/drm/exynos/exynos_drm_vidi.c | 2 --
 1 file changed, 2 deletions(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/exynos/exynos_drm_vidi.c

drivers/gpu/drm/exynos/exynos_drm_vidi.c static int vidi_remove(struct platform_device *pdev) · line 473

Quoted 9 lines

index 4d56c8c799c5..f5e1adfcaa51 100644

drivers/gpu/drm/exynos/exynos_drm_vidi.c +0 -2
@@ -469,8 +469,6 @@ static int vidi_remove(struct platform_device *pdev)
 	if (ctx->raw_edid != (struct edid *)fake_edid_info) {
 		kfree(ctx->raw_edid);
 		ctx->raw_edid = NULL;
-
-		return -EINVAL;

It doesn't look right to me, I think the correct patch should be:

(quoted diff) +1 -7
-       if (ctx->raw_edid != (struct edid *)fake_edid_info) {
-               kfree(ctx->raw_edid);
-               ctx->raw_edid = NULL;
-
-               return -EINVAL;
-       }
-
+       ctx->raw_edid = NULL;
Quoted 7 lines

because "ctx->raw_edid" points to a non allocated memory in the .data segment and you cannot free it.

A follow-up cleanup should be to remove the "const" from fake_edid_info because you are assigning its address to pointers (raw_edid), so that what's the point for having it const? You are just fooling the compiler :)

Thanks for review comment.

"ctx->raw_edid != fake_edid_info" means that the edid sent by the user through the ictl system call - vidi_connection_ioctl - is used instead of fake one - face_edid_info.
In this case, ctx->raw_edid object needs to be released because ctx->raw_edid object is allocated and the edid object sent by user is copied to the ctx-

Quoted 1 line

raw_edid by kmemdup(). :)

Thanks,
Inki Dae

Quoted 8 lines

Andi

Quoted 5 lines
drivers/gpu/drm/exynos/exynos_drm_vidi.c +0 -1
 	}
 
 	component_del(&pdev->dev, &vidi_component_ops);
--

2.25.1

#5 lore raw

Hi Inki,

Quoted 28 lines
Quoted 18 lines

drivers/gpu/drm/exynos/exynos_drm_vidi.c static int vidi_remove(struct platform_device *pdev) · line 473

Quoted 6 lines
drivers/gpu/drm/exynos/exynos_drm_vidi.c +0 -2
@@ -469,8 +469,6 @@ static int vidi_remove(struct platform_device *pdev)
 	if (ctx->raw_edid != (struct edid *)fake_edid_info) {
 		kfree(ctx->raw_edid);
 		ctx->raw_edid = NULL;
-
-		return -EINVAL;

It doesn't look right to me, I think the correct patch should be:

(quoted diff) +1 -7
-       if (ctx->raw_edid != (struct edid *)fake_edid_info) {
-               kfree(ctx->raw_edid);
-               ctx->raw_edid = NULL;
-
-               return -EINVAL;
-       }
-
+       ctx->raw_edid = NULL;
Quoted 7 lines

because "ctx->raw_edid" points to a non allocated memory in the .data segment and you cannot free it.

A follow-up cleanup should be to remove the "const" from fake_edid_info because you are assigning its address to pointers (raw_edid), so that what's the point for having it const? You are just fooling the compiler :)

Thanks for review comment.

Quoted 6 lines

"ctx->raw_edid != fake_edid_info" means that the edid sent by the user through the ictl system call - vidi_connection_ioctl - is used instead of fake one - face_edid_info.
In this case, ctx->raw_edid object needs to be released because ctx->raw_edid object is allocated and the edid object sent by user is copied to the ctx-

Quoted 1 line

raw_edid by kmemdup(). :)

yes... yes... I sent you another e-mail after this :)

Thanks,
Andi

#6 lore raw

2023년 5월 19일 (금) 오후 6:21, Andi Shyti <[email protected]>님이 작성:

Quoted 35 lines

Hi Inki,

Quoted 1 line
Quoted 1 line

Review static int vidi_remove(struct platform_device

Quoted 1 line
(quoted diff) +0 -0
@@ -469,8 +469,6 @@ static int vidi_remove(struct platform_device

*pdev)

Quoted 20 lines
Quoted 20 lines

drivers/gpu/drm/exynos/exynos_drm_vidi.c static int vidi_remove(struct platform_device *pdev) · line 473

Quoted 5 lines
drivers/gpu/drm/exynos/exynos_drm_vidi.c +0 -2
  if (ctx->raw_edid != (struct edid *)fake_edid_info) {
          kfree(ctx->raw_edid);
          ctx->raw_edid = NULL;
-
-         return -EINVAL;

It doesn't look right to me, I think the correct patch should be:

(quoted diff) +1 -7
-       if (ctx->raw_edid != (struct edid *)fake_edid_info) {
-               kfree(ctx->raw_edid);
-               ctx->raw_edid = NULL;
-
-               return -EINVAL;
-       }
-
+       ctx->raw_edid = NULL;

because "ctx->raw_edid" points to a non allocated memory in the .data segment and you cannot free it.

Quoted 8 lines
Quoted 4 lines

A follow-up cleanup should be to remove the "const" from fake_edid_info because you are assigning its address to pointers (raw_edid), so that what's the point for having it const? You are just fooling the compiler :)

Thanks for review comment.

"ctx->raw_edid != fake_edid_info" means that the edid sent by the user

through

Quoted 1 line

the ictl system call - vidi_connection_ioctl - is used instead of fake

one -

Quoted 9 lines
Quoted 2 lines

face_edid_info.
In this case, ctx->raw_edid object needs to be released because

ctx->raw_edid

Quoted 1 line

object is allocated and the edid object sent by user is copied to the

ctx-

Quoted 1 line
Quoted 1 line

raw_edid by kmemdup(). :)

yes... yes... I sent you another e-mail after this :)

I didn't check the second email you sent. :)

Thanks,
Inki Dae

Quoted 3 lines

Thanks,
Andi