drivers/gpu/drm/radeon/r600_blit.c: fix possible NULL pointer derefernce
Subsystems (2)
This patch fix possible NULL pointer dereference when r600_prepare_blit_copy tries to fill dev_priv->blit_vb->file_priv without check of dev_priv->blit_vb. dev_priv->blit_vb should be filled by r600_nomm_get_vb but latest can fail with EAGAIN.
Addresses: https://bugzilla.kernel.org/show_bug.cgi?id=16375
--- drivers/gpu/drm/radeon/r600_blit.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
drivers/gpu/drm/radeon/r600_blit.c +2 -0
@@ -541,6 +541,8 @@ r600_prepare_blit_copy(struct drm_device *dev, struct drm_file *file_priv)DRM_DEBUG ("\n" );r600_nomm_get_vb (dev); +if (!dev_priv->blit_vb) +return ; dev_priv->blit_vb->file_priv = file_priv;
--
1.7.1.1
Quoted 15 lines · Alexander Y. Fomichev
This patch fix possible NULL pointer dereference when
r600_prepare_blit_copytries to filldev_priv->blit_vb->file_privwithout check ofdev_priv->blit_vb.dev_priv->blit_vbshould be filled byr600_nomm_get_vbbut latest can fail with EAGAIN.
Addresses: https://bugzilla.kernel.org/show_bug.cgi?id=16375---
drivers/gpu/drm/radeon/r600_blit.c | 2 ++1 files changed, 2 insertions(+), 0 deletions(-)drivers/gpu/drm/radeon/r600_blit.c +0
-0
drivers/gpu/drm/radeon/r600_blit.c r600_prepare_blit_copy(struct drm_device *dev, struct drm_file *file_priv) · line 545
Quoted 5 lines
drivers/gpu/drm/radeon/r600_blit.c +2
-0@@ -541,6 +541,8 @@ r600_prepare_blit_copy(struct drm_device *dev, struct drm_file *file_priv) DRM_DEBUG("\n"); r600_nomm_get_vb(dev); + if (!dev_priv->blit_vb) + return;
r600_prepare_blit_copy returns an int so something like this would be better:
drivers/gpu/drm/radeon/r600_blit.c +0 -0
@@ -539,8 +539,10 @@ r600_prepare_blit_copy(struct drm_device *dev,
struct drm_file *file_priv)
{
drm_radeon_private_t *dev_priv = dev->dev_private;
DRM_DEBUG("\n");+ int ret = r600_nomm_get_vb(dev);
- r600_nomm_get_vb(dev);
+ if (ret)
+ return ret;
dev_priv->blit_vb->file_priv = file_priv;
Alex
Quoted 6 lines
drivers/gpu/drm/radeon/r600_blit.c +0
-1dev_priv->blit_vb->file_priv = file_priv; --1.7.1.1
Quoted 40 lines · Alex Deucher
Quoted 15 lines · Alexander Y. Fomichev
This patch fix possible NULL pointer dereference when
r600_prepare_blit_copytries to filldev_priv->blit_vb->file_privwithout check ofdev_priv->blit_vb.dev_priv->blit_vbshould be filled byr600_nomm_get_vbbut latest can fail with EAGAIN.
Addresses: https://bugzilla.kernel.org/show_bug.cgi?id=16375---
drivers/gpu/drm/radeon/r600_blit.c | 2 ++1 files changed, 2 insertions(+), 0 deletions(-)drivers/gpu/drm/radeon/r600_blit.c +0
-0drivers/gpu/drm/radeon/r600_blit.c r600_prepare_blit_copy(struct drm_device *dev, struct drm_file *file_priv) · line 545
Quoted 5 lines
drivers/gpu/drm/radeon/r600_blit.c +2
-0@@ -541,6 +541,8 @@ r600_prepare_blit_copy(struct drm_device *dev, struct drm_file *file_priv) DRM_DEBUG("\n"); r600_nomm_get_vb(dev); + if (!dev_priv->blit_vb) + return;
r600_prepare_blit_copyreturns an int so something like this would be better:drivers/gpu/drm/radeon/r600_blit.c +3
-1@@ -539,8 +539,10 @@ r600_prepare_blit_copy(struct drm_device *dev, struct drm_file *file_priv) { drm_radeon_private_t *dev_priv = dev->dev_private; DRM_DEBUG("\n"); + int ret = r600_nomm_get_vb(dev); - r600_nomm_get_vb(dev); + if (ret) + return ret; dev_priv->blit_vb->file_priv = file_priv;
Quoted 9 lines
Alex
Quoted 6 lines
drivers/gpu/drm/radeon/r600_blit.c +0
-1dev_priv->blit_vb->file_priv = file_priv; --1.7.1.1
i haven't any preferneces, the only thing is - it would be logical to have every check in common style, so other cases (r600_blit_copy, r600_blit_swap) should be fixed, nop?
Signature · 2 lines
Best regards. Alexander Y. Fomichev <[email protected]>
Quoted 46 lines · Alexander Y. Fomichev
Quoted 45 lines · Alex Deucher
Quoted 15 lines · Alexander Y. Fomichev
This patch fix possible NULL pointer dereference when
r600_prepare_blit_copytries to filldev_priv->blit_vb->file_privwithout check ofdev_priv->blit_vb.dev_priv->blit_vbshould be filled byr600_nomm_get_vbbut latest can fail with EAGAIN.
Addresses: https://bugzilla.kernel.org/show_bug.cgi?id=16375---
drivers/gpu/drm/radeon/r600_blit.c | 2 ++1 files changed, 2 insertions(+), 0 deletions(-)drivers/gpu/drm/radeon/r600_blit.c +0
-0drivers/gpu/drm/radeon/r600_blit.c r600_prepare_blit_copy(struct drm_device *dev, struct drm_file *file_priv) · line 545
Quoted 5 lines
drivers/gpu/drm/radeon/r600_blit.c +2
-0@@ -541,6 +541,8 @@ r600_prepare_blit_copy(struct drm_device *dev, struct drm_file *file_priv) DRM_DEBUG("\n"); r600_nomm_get_vb(dev); + if (!dev_priv->blit_vb) + return;
r600_prepare_blit_copyreturns an int so something like this would be better:drivers/gpu/drm/radeon/r600_blit.c +3
-1@@ -539,8 +539,10 @@ r600_prepare_blit_copy(struct drm_device *dev, struct drm_file *file_priv) { drm_radeon_private_t *dev_priv = dev->dev_private; DRM_DEBUG("\n"); + int ret = r600_nomm_get_vb(dev); - r600_nomm_get_vb(dev); + if (ret) + return ret; dev_priv->blit_vb->file_priv = file_priv;Alex
Quoted 3 lines
drivers/gpu/drm/radeon/r600_blit.c +0
-0dev_priv->blit_vb->file_priv = file_priv;
Quoted 8 lines
Quoted 4 lines
Quoted 3 lines
drivers/gpu/drm/radeon/r600_blit.c +0
-1--1.7.1.1
i haven't any preferneces, the only thing is - it would be logical to have every check in common style, so other cases (
r600_blit_copy,r600_blit_swap) should be fixed, nop?
Those are void functions so there's nothing to return.
Alex
Quoted 5 lines
--
Best regards.
Alexander Y. Fomichev <[email protected]>
Quoted 53 lines · Alex Deucher
Quoted 51 lines · Alexander Y. Fomichev
Quoted 49 lines · Alex Deucher
Quoted 15 lines · Alexander Y. Fomichev
This patch fix possible NULL pointer dereference when
r600_prepare_blit_copytries to filldev_priv->blit_vb->file_privwithout check ofdev_priv->blit_vb.dev_priv->blit_vbshould be filled byr600_nomm_get_vbbut latest can fail with EAGAIN.
Addresses: https://bugzilla.kernel.org/show_bug.cgi?id=16375---
drivers/gpu/drm/radeon/r600_blit.c | 2 ++1 files changed, 2 insertions(+), 0 deletions(-)drivers/gpu/drm/radeon/r600_blit.c +0
-0drivers/gpu/drm/radeon/r600_blit.c r600_prepare_blit_copy(struct drm_device *dev, struct drm_file *file_priv) · line 545
Quoted 5 lines
drivers/gpu/drm/radeon/r600_blit.c +2
-0@@ -541,6 +541,8 @@ r600_prepare_blit_copy(struct drm_device *dev, struct drm_file *file_priv) DRM_DEBUG("\n"); r600_nomm_get_vb(dev); + if (!dev_priv->blit_vb) + return;
r600_prepare_blit_copyreturns an int so something like this would be better:drivers/gpu/drm/radeon/r600_blit.c +3
-1@@ -539,8 +539,10 @@ r600_prepare_blit_copy(struct drm_device *dev, struct drm_file *file_priv) { drm_radeon_private_t *dev_priv = dev->dev_private; DRM_DEBUG("\n"); + int ret = r600_nomm_get_vb(dev); - r600_nomm_get_vb(dev); + if (ret) + return ret; dev_priv->blit_vb->file_priv = file_priv;Alex
Quoted 6 lines
drivers/gpu/drm/radeon/r600_blit.c +0
-1dev_priv->blit_vb->file_priv = file_priv; --1.7.1.1
Quoted 5 lines
Quoted 3 lines
i haven't any preferneces, the only thing is - it would be logical to have every check in common style, so other cases (
r600_blit_copy,r600_blit_swap) should be fixed, nop?Those are void functions so there's nothing to return.
i mean both of them call r600_nomm_get_vb and both of them check if (!dev_priv->blit_vb), not return value.I mean would be logical to check it the same way everytime r600_nomm_get_vb gets called.
Quoted 8 lines
Alex
Quoted 5 lines
--
Best regards.
Alexander Y. Fomichev <[email protected]>
Signature · 2 lines
Best regards. Alexander Y. Fomichev <[email protected]>
Quoted 58 lines · Alexander Y. Fomichev
Quoted 57 lines · Alex Deucher
Quoted 54 lines · Alexander Y. Fomichev
Quoted 40 lines · Alex Deucher
Quoted 15 lines · Alexander Y. Fomichev
This patch fix possible NULL pointer dereference when
r600_prepare_blit_copytries to filldev_priv->blit_vb->file_privwithout check ofdev_priv->blit_vb.dev_priv->blit_vbshould be filled byr600_nomm_get_vbbut latest can fail with EAGAIN.
Addresses: https://bugzilla.kernel.org/show_bug.cgi?id=16375---
drivers/gpu/drm/radeon/r600_blit.c | 2 ++1 files changed, 2 insertions(+), 0 deletions(-)drivers/gpu/drm/radeon/r600_blit.c +0
-0drivers/gpu/drm/radeon/r600_blit.c r600_prepare_blit_copy(struct drm_device *dev, struct drm_file *file_priv) · line 545
Quoted 5 lines
drivers/gpu/drm/radeon/r600_blit.c +2
-0@@ -541,6 +541,8 @@ r600_prepare_blit_copy(struct drm_device *dev, struct drm_file *file_priv) DRM_DEBUG("\n"); r600_nomm_get_vb(dev); + if (!dev_priv->blit_vb) + return;
r600_prepare_blit_copyreturns an int so something like this would be better:drivers/gpu/drm/radeon/r600_blit.c +3
-1@@ -539,8 +539,10 @@ r600_prepare_blit_copy(struct drm_device *dev, struct drm_file *file_priv) { drm_radeon_private_t *dev_priv = dev->dev_private; DRM_DEBUG("\n"); + int ret = r600_nomm_get_vb(dev); - r600_nomm_get_vb(dev); + if (ret) + return ret; dev_priv->blit_vb->file_priv = file_priv;Quoted 9 lines
Alex
Quoted 6 lines
drivers/gpu/drm/radeon/r600_blit.c +0
-1dev_priv->blit_vb->file_priv = file_priv; --1.7.1.1
i haven't any preferneces, the only thing is - it would be logical to have every check in common style, so other cases (
r600_blit_copy,r600_blit_swap) should be fixed, nop?
Quoted 6 lines
Quoted 1 line
Those are void functions so there's nothing to return.
i mean both of them call
r600_nomm_get_vband both of them check if (!dev_priv->blit_vb), not return value.I mean would be logical to check it the same way everytimer600_nomm_get_vbgets called.
yeah, either way. You just need to return an error in r600_prepare_blit_copy.
Alex
Quoted 16 lines
Quoted 9 lines
Alex
Quoted 5 lines
--
Best regards.
Alexander Y. Fomichev <[email protected]>--
Best regards.
Alexander Y. Fomichev <[email protected]>
Quoted 60 lines · Alex Deucher
Quoted 58 lines · Alexander Y. Fomichev
Quoted 57 lines · Alex Deucher
Quoted 54 lines · Alexander Y. Fomichev
Quoted 40 lines · Alex Deucher
Quoted 15 lines · Alexander Y. Fomichev
This patch fix possible NULL pointer dereference when
r600_prepare_blit_copytries to filldev_priv->blit_vb->file_privwithout check ofdev_priv->blit_vb.dev_priv->blit_vbshould be filled byr600_nomm_get_vbbut latest can fail with EAGAIN.
Addresses: https://bugzilla.kernel.org/show_bug.cgi?id=16375---
drivers/gpu/drm/radeon/r600_blit.c | 2 ++1 files changed, 2 insertions(+), 0 deletions(-)drivers/gpu/drm/radeon/r600_blit.c +0
-0drivers/gpu/drm/radeon/r600_blit.c r600_prepare_blit_copy(struct drm_device *dev, struct drm_file *file_priv) · line 545
Quoted 5 lines
drivers/gpu/drm/radeon/r600_blit.c +2
-0@@ -541,6 +541,8 @@ r600_prepare_blit_copy(struct drm_device *dev, struct drm_file *file_priv) DRM_DEBUG("\n"); r600_nomm_get_vb(dev); + if (!dev_priv->blit_vb) + return;
r600_prepare_blit_copyreturns an int so something like this would be better:drivers/gpu/drm/radeon/r600_blit.c +3
-1@@ -539,8 +539,10 @@ r600_prepare_blit_copy(struct drm_device *dev, struct drm_file *file_priv) { drm_radeon_private_t *dev_priv = dev->dev_private; DRM_DEBUG("\n"); + int ret = r600_nomm_get_vb(dev); - r600_nomm_get_vb(dev); + if (ret) + return ret; dev_priv->blit_vb->file_priv = file_priv;Quoted 9 lines
Alex
Quoted 6 lines
drivers/gpu/drm/radeon/r600_blit.c +0
-1dev_priv->blit_vb->file_priv = file_priv; --1.7.1.1
i haven't any preferneces, the only thing is - it would be logical to have every check in common style, so other cases (
r600_blit_copy,r600_blit_swap) should be fixed, nop?
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
Those are void functions so there's nothing to return.
i mean both of them call
r600_nomm_get_vband both of them check if (!dev_priv->blit_vb), not return value.I mean would be logical to check it the same way everytimer600_nomm_get_vbgets called.yeah, either way. You just need to return an error in
r600_prepare_blit_copy.
uh-huh, i've missed
Quoted 19 lines
Alex
Quoted 16 lines
Quoted 9 lines
Alex
Quoted 5 lines
--
Best regards.
Alexander Y. Fomichev <[email protected]>--
Best regards.
Alexander Y. Fomichev <[email protected]>
Signature · 2 lines
Best regards. Alexander Y. Fomichev <[email protected]>
Quoted 58 lines · Alexander Y. Fomichev
Quoted 57 lines · Alex Deucher
Quoted 54 lines · Alexander Y. Fomichev
Quoted 40 lines · Alex Deucher
Quoted 15 lines · Alexander Y. Fomichev
This patch fix possible NULL pointer dereference when
r600_prepare_blit_copytries to filldev_priv->blit_vb->file_privwithout check ofdev_priv->blit_vb.dev_priv->blit_vbshould be filled byr600_nomm_get_vbbut latest can fail with EAGAIN.
Addresses: https://bugzilla.kernel.org/show_bug.cgi?id=16375--- drivers/gpu/drm/radeon/r600_blit.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)drivers/gpu/drm/radeon/r600_blit.c +0
-0drivers/gpu/drm/radeon/r600_blit.c r600_prepare_blit_copy(struct drm_device *dev, struct drm_file *file_priv) · line 545
Quoted 5 lines
drivers/gpu/drm/radeon/r600_blit.c +2
-0@@ -541,6 +541,8 @@ r600_prepare_blit_copy(struct drm_device *dev, struct drm_file *file_priv)DRM_DEBUG ("\n" );r600_nomm_get_vb (dev); +if (!dev_priv->blit_vb) +return ;
r600_prepare_blit_copyreturns an int so something like this would be better:drivers/gpu/drm/radeon/r600_blit.c +3
-1@@ -539,8 +539,10 @@ r600_prepare_blit_copy(struct drm_device *dev, struct drm_file *file_priv) {drm_radeon_private_t *dev_priv = dev->dev_private;DRM_DEBUG ("\n" ); +int ret =r600_nomm_get_vb (dev); -r600_nomm_get_vb (dev); +if (ret) +return ret; dev_priv->blit_vb->file_priv = file_priv;Quoted 9 lines
Alex
Quoted 6 lines
drivers/gpu/drm/radeon/r600_blit.c +0
-1dev_priv->blit_vb->file_priv = file_priv; --1.7.1.1
i haven't any preferneces, the only thing is - it would be logical to have every check in common style, so other cases (
r600_blit_copy,r600_blit_swap) should be fixed, nop?
Quoted 6 lines
Quoted 1 line
Those are void functions so there's nothing to return.
i mean both of them call
r600_nomm_get_vband both of them check if (!dev_priv->blit_vb), not return value.I mean would be logical to check it the same way everytimer600_nomm_get_vbgets called.
I'm going to go with Alex's patch, as none of the other callsites return an error, and your patch doesn't return value from a function which has a int return type, causing a warning.
Dave.