coverity
Subsystems (5)
cover coverity
Hi all,
Rainy w/e here and I got a bit bored, so looked at coverity again. I've closed all outstanding issues in drivers/gpu now either as false positives or fixed in this series expect for vmwgfx/ttm stuff (not enough clue) and one insane savage init issue (no desire to wake dragons today).
Cheers, Daniel
Daniel Vetter (13):
drm/mgag200: Remove unnecessary NULL check in bo_unref drm/mgag200: Remove unecessary NULL check in gem_free drm/cirrus: Remove unnecessary NULL check in bo_unref drm/cirrus: Remove unecessary NULL check in gem_free drm/ast: Remove unnecessary NULL check in bo_unref drm/mgag200: Remove unecessary NULL check in gem_free drm/via: Remove unecessary NULL check drm/ast: Remove dead code from cbr_scan2 drm/udl: Initialize ret in udl_driver_load drm/bochs: Remove unnecessary NULL check in bo_unref drm/bochs: Remove unecessary NULL check in gem_free drm/i2c/tda998x: Fix signed overflow issue
drm: Fix error handling in drm_master_create
drivers/gpu/drm/ast/ast_main.c | 7 ++----- drivers/gpu/drm/ast/ast_post.c | 2 -- drivers/gpu/drm/bochs/bochs_mm.c | 6 +----- drivers/gpu/drm/cirrus/cirrus_main.c | 6 +----- drivers/gpu/drm/drm_stub.c | 5 ++++- drivers/gpu/drm/i2c/tda998x_drv.c | 2 +- drivers/gpu/drm/mgag200/mgag200_main.c | 6 +----- drivers/gpu/drm/udl/udl_main.c | 1 + drivers/gpu/drm/via/via_mm.c | 2 +- 9 files changed, 12 insertions(+), 25 deletions(-)
Signature · 1 line
1.8.5.2
cover coverity
Hi all,
Rainy w/e here and I got a bit bored, so looked at coverity again. I've closed all outstanding issues in drivers/gpu now either as false positives or fixed in this series expect for vmwgfx/ttm stuff (not enough clue) and one insane savage init issue (no desire to wake dragons today).
Cheers, Daniel
Daniel Vetter (13):
drm/mgag200: Remove unnecessary NULL check in bo_unref drm/mgag200: Remove unecessary NULL check in gem_free drm/cirrus: Remove unnecessary NULL check in bo_unref drm/cirrus: Remove unecessary NULL check in gem_free drm/ast: Remove unnecessary NULL check in bo_unref drm/mgag200: Remove unecessary NULL check in gem_free drm/via: Remove unecessary NULL check drm/ast: Remove dead code from cbr_scan2 drm/udl: Initialize ret in udl_driver_load drm/bochs: Remove unnecessary NULL check in bo_unref drm/bochs: Remove unecessary NULL check in gem_free drm/i2c/tda998x: Fix signed overflow issue
drm: Fix error handling in drm_master_create
drivers/gpu/drm/ast/ast_main.c | 7 ++----- drivers/gpu/drm/ast/ast_post.c | 2 -- drivers/gpu/drm/bochs/bochs_mm.c | 6 +----- drivers/gpu/drm/cirrus/cirrus_main.c | 6 +----- drivers/gpu/drm/drm_stub.c | 5 ++++- drivers/gpu/drm/i2c/tda998x_drv.c | 2 +- drivers/gpu/drm/mgag200/mgag200_main.c | 6 +----- drivers/gpu/drm/udl/udl_main.c | 1 + drivers/gpu/drm/via/via_mm.c | 2 +- 9 files changed, 12 insertions(+), 25 deletions(-)
Signature · 1 line
1.8.5.2
Hi
Quoted 6 lines · Daniel Vetter
Hi all,
Rainy w/e here and I got a bit bored, so looked at coverity again. I've closed all outstanding issues in
drivers/gpunow either as false positives or fixed in this series expect for vmwgfx/ttm stuff (not enough clue) and one insane savage init issue (no desire to wake dragons today).
All patches besides "drm/ast: Remove dead code from cbr_scan2" are:
However, a few notes:
- ttm_bo_unref() sets "bo = NULL;", so the following condition is always true. Your commit-message argues with an unconditional kref_unref(). I think that's misleading (but still true) as that does not change the fact that bo is always NULL afterwards.
- I am a big fan of "if (!obj) return;" in destructors. It simplifies error-paths considerably and we can call them despite objects being already cleared. But that's just personal style, and I don't deal much with TTM anyway. But generally, I think we shouldn't remove these checks blindly.
- The AST patch should be reviewed by someone who knows that hw. The code is obviously wrong, but that doesn't mean we cannot fix it properly.
Thanks for the cleanups, the coverity reports have been pending here for months..
David
PATCH 1/13 drm/mgag200: Remove unnecessary NULL check in bo_unref
In reply to Daniel Vetterttm_bo_unref unconditionally calls kref_put on it's argument, so the thing can't be NULL without already causing Oopses.
Spotted by coverity.
--- drivers/gpu/drm/mgag200/mgag200_main.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/gpu/drm/mgag200/mgag200_main.c +1 -3
@@ -322,9 +322,7 @@ static void mgag200_bo_unref(struct mgag200_bo **bo) tbo = &((*bo)->bo);ttm_bo_unref (&tbo); -if (tbo ==NULL ) - *bo =NULL ; - + *bo =NULL ; }void mgag200_gem_free_object (struct drm_gem_object *obj)
Signature · 1 line
1.8.5.2
Re: [PATCH 01/13] drm/mgag200: Remove unnecessary NULL check in bo_unref
Quoted 2 lines · Daniel Vetter
ttm_bo_unrefunconditionally callskref_puton it's argument, so the thing can't be NULL without already causing Oopses.
Doesn't this mean the NULL check is in the wrong place (rather than the NULL check should be removed)?
Quoted 23 lines
Spotted by coverity.
Signed-off-by Daniel Vetter <[email protected]>--- drivers/gpu/drm/mgag200/mgag200_main.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)drivers/gpu/drm/mgag200/mgag200_main.c +1
-3@@ -322,9 +322,7 @@ static void mgag200_bo_unref(struct mgag200_bo **bo) tbo = &((*bo)->bo);ttm_bo_unref (&tbo); -if (tbo ==NULL ) - *bo =NULL ; - + *bo =NULL ; }void mgag200_gem_free_object (struct drm_gem_object *obj)
Re: [PATCH 01/13] drm/mgag200: Remove unnecessary NULL check in bo_unref
Quoted 6 lines · Ian Romanick
Quoted 2 lines · Daniel Vetter
ttm_bo_unrefunconditionally callskref_puton it's argument, so the thing can't be NULL without already causing Oopses.Doesn't this mean the NULL check is in the wrong place (rather than the NULL check should be removed)?
Afaics chasing callchains it's a bug to call this with NULL pointer and no one really should be doing it. Like David Herrmann said it's sometimes useful if unref/free functions automatically cope with NULL, but ttm buffers don't seem to be of this kind. So consistency with other ttm drivers seems better, same with all the gem_free_object callbacks.
-Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Ian Romanick
Reviewed-byRe: [PATCH 01/13] drm/mgag200: Remove unnecessary NULL check in bo_unref
Quoted 8 lines · Daniel Vetter
Quoted 6 lines · Ian Romanick
Quoted 2 lines · Daniel Vetter
ttm_bo_unrefunconditionally callskref_puton it's argument, so the thing can't be NULL without already causing Oopses.Doesn't this mean the NULL check is in the wrong place (rather than the NULL check should be removed)?
Quoted 6 lines
Afaics chasing callchains it's a bug to call this with NULL pointer and no one really should be doing it. Like David Herrmann said it's sometimes useful if unref/free functions automatically cope with NULL, but ttm buffers don't seem to be of this kind. So consistency with other ttm drivers seems better, same with all the
gem_free_objectcallbacks.
That's fair. I'm convinced. Patches 1, 3, and 5 are also
Quoted 1 line
-Daniel
PATCH 2/13 drm/mgag200: Remove unecessary NULL check in gem_free
In reply to Daniel VetterThe ->gem_free_object never gets called with a NULL pointer, the check is redundant. Also checking after the upcast allows compilers to elide it anyway.
Spotted by coverity.
--- drivers/gpu/drm/mgag200/mgag200_main.c | 2 -- 1 file changed, 2 deletions(-)
drivers/gpu/drm/mgag200/mgag200_main.c +0 -2
@@ -329,8 +329,6 @@ void mgag200_gem_free_object(struct drm_gem_object *obj) {struct mgag200_bo *mgag200_bo =gem_to_mga_bo (obj); -if (!mgag200_bo) -return ;mgag200_bo_unref (&mgag200_bo); }
Signature · 1 line
1.8.5.2
Re: [PATCH 02/13] drm/mgag200: Remove unecessary NULL check in gem_free
Quoted 3 lines · Daniel Vetter
The ->gem_free_object never gets called with a NULL pointer, the check is redundant. Also checking after the upcast allows compilers to elide it anyway.
Right... because if obj was NULL, subtracting some offset from it won't still be NULL.
Quoted 3 lines
Spotted by coverity.
Signed-off-by Daniel Vetter <[email protected]>
Quoted 18 lines
--- drivers/gpu/drm/mgag200/mgag200_main.c | 2 -- 1 file changed, 2 deletions(-)drivers/gpu/drm/mgag200/mgag200_main.c +0
-2@@ -329,8 +329,6 @@ void mgag200_gem_free_object(struct drm_gem_object *obj) {struct mgag200_bo *mgag200_bo =gem_to_mga_bo (obj); -if (!mgag200_bo) -return ;mgag200_bo_unref (&mgag200_bo); }
PATCH 3/13 drm/cirrus: Remove unnecessary NULL check in bo_unref
In reply to Daniel Vetterttm_bo_unref unconditionally calls kref_put on it's argument, so the thing can't be NULL without already causing Oopses.
Spotted by coverity.
--- drivers/gpu/drm/cirrus/cirrus_main.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/gpu/drm/cirrus/cirrus_main.c +1 -3
@@ -264,9 +264,7 @@ static void cirrus_bo_unref(struct cirrus_bo **bo) tbo = &((*bo)->bo);ttm_bo_unref (&tbo); -if (tbo ==NULL ) - *bo =NULL ; - + *bo =NULL ; }void cirrus_gem_free_object (struct drm_gem_object *obj)
Signature · 1 line
1.8.5.2
PATCH 4/13 drm/cirrus: Remove unecessary NULL check in gem_free
In reply to Daniel VetterThe ->gem_free_object never gets called with a NULL pointer, the check is redundant. Also checking after the upcast allows compilers to elide it anyway.
Spotted by coverity.
--- drivers/gpu/drm/cirrus/cirrus_main.c | 2 -- 1 file changed, 2 deletions(-)
drivers/gpu/drm/cirrus/cirrus_main.c +0 -2
@@ -271,8 +271,6 @@ void cirrus_gem_free_object(struct drm_gem_object *obj) {struct cirrus_bo *cirrus_bo =gem_to_cirrus_bo (obj); -if (!cirrus_bo) -return ;cirrus_bo_unref (&cirrus_bo); }
Signature · 1 line
1.8.5.2
Re: [PATCH 04/13] drm/cirrus: Remove unecessary NULL check in gem_free
Quoted 7 lines · Daniel Vetter
The ->gem_free_object never gets called with a NULL pointer, the check is redundant. Also checking after the upcast allows compilers to elide it anyway.
Spotted by coverity.
Signed-off-by Daniel Vetter <[email protected]>
Same as MGA change.
Quoted 18 lines
--- drivers/gpu/drm/cirrus/cirrus_main.c | 2 -- 1 file changed, 2 deletions(-)drivers/gpu/drm/cirrus/cirrus_main.c +0
-2@@ -271,8 +271,6 @@ void cirrus_gem_free_object(struct drm_gem_object *obj) {struct cirrus_bo *cirrus_bo =gem_to_cirrus_bo (obj); -if (!cirrus_bo) -return ;cirrus_bo_unref (&cirrus_bo); }
PATCH 5/13 drm/ast: Remove unnecessary NULL check in bo_unref
In reply to Daniel Vetterttm_bo_unref unconditionally calls kref_put on it's argument, so the thing can't be NULL without already causing Oopses.
Spotted by coverity.
--- drivers/gpu/drm/ast/ast_main.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/gpu/drm/ast/ast_main.c +2 -3
@@ -411,10 +411,9 @@ static void ast_bo_unref(struct ast_bo **bo) tbo = &((*bo)->bo);ttm_bo_unref (&tbo); -if (tbo ==NULL ) - *bo =NULL ; - + *bo =NULL ; } +void ast_gem_free_object (struct drm_gem_object *obj) {struct ast_bo *ast_bo =gem_to_ast_bo (obj);
Signature · 1 line
1.8.5.2
PATCH 6/13 drm/mgag200: Remove unecessary NULL check in gem_free
In reply to Daniel VetterThe ->gem_free_object never gets called with a NULL pointer, the check is redundant. Also checking after the upcast allows compilers to elide it anyway.
Spotted by coverity.
--- drivers/gpu/drm/ast/ast_main.c | 2 -- 1 file changed, 2 deletions(-)
drivers/gpu/drm/ast/ast_main.c +0 -2
@@ -418,8 +418,6 @@ void ast_gem_free_object(struct drm_gem_object *obj) {struct ast_bo *ast_bo =gem_to_ast_bo (obj); -if (!ast_bo) -return ;ast_bo_unref (&ast_bo); }
Signature · 1 line
1.8.5.2
PATCH 1/1 drm/ast: Remove unecessary NULL check in gem_free
The ->gem_free_object never gets called with a NULL pointer, the check is redundant. Also checking after the upcast allows compilers to elide it anyway.
Spotted by coverity.
v2: Fix patch subject.
--- drivers/gpu/drm/ast/ast_main.c | 2 -- 1 file changed, 2 deletions(-)
drivers/gpu/drm/ast/ast_main.c +0 -2
@@ -418,8 +418,6 @@ void ast_gem_free_object(struct drm_gem_object *obj) {struct ast_bo *ast_bo =gem_to_ast_bo (obj); -if (!ast_bo) -return ;ast_bo_unref (&ast_bo); }
Signature · 1 line
1.8.5.2
Re: [PATCH 06/13] drm/mgag200: Remove unecessary NULL check in gem_free
In reply to Daniel VetterQuoted 7 lines · Daniel Vetter
The ->gem_free_object never gets called with a NULL pointer, the check is redundant. Also checking after the upcast allows compilers to elide it anyway.
Spotted by coverity.
Signed-off-by Daniel Vetter <[email protected]>
Same as MGA change.
Quoted 18 lines
--- drivers/gpu/drm/ast/ast_main.c | 2 -- 1 file changed, 2 deletions(-)drivers/gpu/drm/ast/ast_main.c +0
-2@@ -418,8 +418,6 @@ void ast_gem_free_object(struct drm_gem_object *obj) {struct ast_bo *ast_bo =gem_to_ast_bo (obj); -if (!ast_bo) -return ;ast_bo_unref (&ast_bo); }
PATCH 7/13 drm/via: Remove unecessary NULL check
In reply to Daniel VetterThe context_dtor callback is only called once we've successfully loaded the driver, which means dev->dev_private is set up. The check is hence pointless.
Also dev->dev_private is deref already above, so compilers are free to elide it anyway.
--- drivers/gpu/drm/via/via_mm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/via/via_mm.c +1 -1
@@ -79,7 +79,7 @@ int via_final_context(struct drm_device *dev, int context)/* Linux specific until context tracking code gets ported to BSD */ /* Last context, perform cleanup */ -if (list_is_singular (&dev->ctxlist) && dev->dev_private) { +if (list_is_singular (&dev->ctxlist)) {DRM_DEBUG ("Last Context\n" );drm_irq_uninstall (dev);via_cleanup_futex (dev_priv);
Signature · 1 line
1.8.5.2
Re: [PATCH 07/13] drm/via: Remove unecessary NULL check
Hi
Quoted 6 lines · Daniel Vetter
The
context_dtorcallback is only called once we've successfully loaded the driver, which meansdev->dev_privateis set up. The check is hence pointless.Also
dev->dev_privateis deref already above, so compilers are free to elide it anyway.
Are you sure compilers can assume "*ptr" implies "ptr != NULL"? I doubt that and depending on CONFIG_DEFAULT_MMAP_MIN_ADDR I think you can even build user-space that can successfully mmap(MAP_FIXED) at address 0. Anyhow, I guess no-one cares besides me, so patch looks good :)
Thanks
David
Re: [PATCH 07/13] drm/via: Remove unecessary NULL check
Quoted 5 lines · David Herrmann
Quoted 4 lines · Daniel Vetter
The
context_dtorcallback is only called once we've successfully loaded the driver, which meansdev->dev_privateis set up. The check is hence pointless.
Quoted 8 lines
Quoted 2 lines
Also
dev->dev_privateis deref already above, so compilers are free to elide it anyway.Are you sure compilers can assume "*ptr" implies "ptr != NULL"? I doubt that and depending on
CONFIG_DEFAULT_MMAP_MIN_ADDRI think you can even build user-space that can successfullymmap(MAP_FIXED)at address 0. Anyhow, I guess no-one cares besides me, so patch looks good :)
Yeah, my understand has been that every time you deref a pointer somewhere the compiler is allowed to presume that the pointer isn't NULL. Which makes mmap(MAP_FIXED) at address NULL such a dangerous thing and iirc there's been patches floating around to severely restrict that to make exploiting such bugs much harder. Iirc it's only emulators like dosemu who really need to be able to map something at NULL. Since if gcc drops the NULL check the last line of defense (namely Oopsing on the NULL deref) can be disabled by userspace. The usual exploit is to put a real data structure at NULL and use that (thorugh vtables if possible) to take over the kernel.
I'm not always entirely sure on what the precise rules are really in detail, but since coverity screamed at me about this here I've figured coverity is probably right ;-)
-Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
PATCH 8/13 drm/ast: Remove dead code from cbr_scan2
In reply to Daniel VetterThe outer if already checks for data != 0, so it can't really be
0. Hence remove it.
Now I don't have specs or anything for this beast, so I have no idea whether this was actually intended or whether the logic should be different. At least the code still seems to be doing something useful.
Spotted by coverity.
--- drivers/gpu/drm/ast/ast_post.c | 2 -- 1 file changed, 2 deletions(-)
drivers/gpu/drm/ast/ast_post.c +0 -2
@@ -572,8 +572,6 @@ static u32 cbr_scan2(struct ast_private *ast)for (loop =0 ; loop <CBR_PASSNUM2 ; loop++) {if ((data =cbr_test2 (ast)) !=0 ) { data2 &= data; -if (!data) -return 0 ;break ; } }
Signature · 1 line
1.8.5.2
Re: [PATCH 08/13] drm/ast: Remove dead code from cbr_scan2
Quoted 21 lines · Daniel Vetter
The outer if already checks for data != 0, so it can't really be
0. Hence remove it.Now I don't have specs or anything for this beast, so I have no idea whether this was actually intended or whether the logic should be different. At least the code still seems to be doing something useful.
Spotted by coverity.
Cc Dave Airlie <[email protected]>Signed-off-by Daniel Vetter <[email protected]>--- drivers/gpu/drm/ast/ast_post.c | 2 -- 1 file changed, 2 deletions(-)drivers/gpu/drm/ast/ast_post.c +0
-0
drivers/gpu/drm/ast/ast_post.c static u32 cbr_scan2(struct ast_private *ast) · line 576
Quoted 5 lines
drivers/gpu/drm/ast/ast_post.c +0
-2@@ -572,8 +572,6 @@ static u32 cbr_scan2(struct ast_private *ast)for (loop =0 ; loop <CBR_PASSNUM2 ; loop++) {if ((data =cbr_test2 (ast)) !=0 ) { data2 &= data; -if (!data) -return 0 ;
That feels like a typo... was that supposed to be 'if (!data2)'?
Quoted 4 lines
drivers/gpu/drm/ast/ast_post.c +0
-0break ; } }
Re: [PATCH 08/13] drm/ast: Remove dead code from cbr_scan2
Quoted 17 lines · Ian Romanick
Quoted 16 lines · Daniel Vetter
The outer if already checks for data != 0, so it can't really be
0. Hence remove it.Now I don't have specs or anything for this beast, so I have no idea whether this was actually intended or whether the logic should be different. At least the code still seems to be doing something useful.
Spotted by coverity.
Cc Dave Airlie <[email protected]>Signed-off-by Daniel Vetter <[email protected]>--- drivers/gpu/drm/ast/ast_post.c | 2 -- 1 file changed, 2 deletions(-)
Quoted 12 lines
drivers/gpu/drm/ast/ast_post.c static u32 cbr_scan2(struct ast_private *ast) · line 576
Quoted 10 lines
drivers/gpu/drm/ast/ast_post.c +0
-2@@ -572,8 +572,6 @@ static u32 cbr_scan2(struct ast_private *ast)for (loop =0 ; loop <CBR_PASSNUM2 ; loop++) {if ((data =cbr_test2 (ast)) !=0 ) { data2 &= data; -if (!data) -return 0 ;That feels like a typo... was that supposed to be 'if (!data2)'?
Yeah this one really needs a close look, since I have no idea what's actually intended behaviour. The patch just removes the dead code as it is now, and the double-loop still makes some sense imo after this change. But I really don't know the spec for this hw. -Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
PATCH 9/13 drm/udl: Initialize ret in udl_driver_load
In reply to Daniel VetterWe need to set it to -ENODEV when we don't recognize the device. Otherwise we return/print stack garbage.
Spotted by coverity.
--- drivers/gpu/drm/udl/udl_main.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/udl/udl_main.c +1 -0
@@ -294,6 +294,7 @@ int udl_driver_load(struct drm_device *dev, unsigned long flags) dev->dev_private = udl;if (!udl_parse_vendor_descriptor (dev, dev->usbdev)) { + ret = -ENODEV ;DRM_ERROR ("firmware not recognized. Assume incompatible device\n" ); goto err; }
Signature · 1 line
1.8.5.2
PATCH 10/13 drm/bochs: Remove unnecessary NULL check in bo_unref
In reply to Daniel Vetterttm_bo_unref unconditionally calls kref_put on it's argument, so the thing can't be NULL without already causing Oopses.
Spotted by coverity.
--- drivers/gpu/drm/bochs/bochs_mm.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/gpu/drm/bochs/bochs_mm.c +1 -3
@@ -434,9 +434,7 @@ static void bochs_bo_unref(struct bochs_bo **bo) tbo = &((*bo)->bo);ttm_bo_unref (&tbo); -if (tbo ==NULL ) - *bo =NULL ; - + *bo =NULL ; }void bochs_gem_free_object (struct drm_gem_object *obj)
Signature · 1 line
1.8.5.2
PATCH 11/13 drm/bochs: Remove unecessary NULL check in gem_free
In reply to Daniel VetterThe ->gem_free_object never gets called with a NULL pointer, the check is redundant. Also checking after the upcast allows compilers to elide it anyway.
Noticed while chasing coverity reports, somehow this one here was not flagged.
--- drivers/gpu/drm/bochs/bochs_mm.c | 2 -- 1 file changed, 2 deletions(-)
drivers/gpu/drm/bochs/bochs_mm.c +0 -2
@@ -441,8 +441,6 @@ void bochs_gem_free_object(struct drm_gem_object *obj) {struct bochs_bo *bochs_bo =gem_to_bochs_bo (obj); -if (!bochs_bo) -return ;bochs_bo_unref (&bochs_bo); }
Signature · 1 line
1.8.5.2
Re: [PATCH 11/13] drm/bochs: Remove unecessary NULL check in gem_free
Quoted 8 lines · Daniel Vetter
The ->gem_free_object never gets called with a NULL pointer, the check is redundant. Also checking after the upcast allows compilers to elide it anyway.
Noticed while chasing coverity reports, somehow this one here was not flagged.
Signed-off-by Daniel Vetter <[email protected]>
Same as MGA change.
Quoted 18 lines
--- drivers/gpu/drm/bochs/bochs_mm.c | 2 -- 1 file changed, 2 deletions(-)drivers/gpu/drm/bochs/bochs_mm.c +0
-2@@ -441,8 +441,6 @@ void bochs_gem_free_object(struct drm_gem_object *obj) {struct bochs_bo *bochs_bo =gem_to_bochs_bo (obj); -if (!bochs_bo) -return ;bochs_bo_unref (&bochs_bo); }
PATCH 12/13 drm/i2c/tda998x: Fix signed overflow issue
In reply to Daniel VetterThis is C standard hair-splitting, but afaict
- sum will be promoted to signed int in computation since uint8_t fits
- signed overflow is undefined.
No we need to add up an awful lot of bytes to actually make it overflow. But I guess the real risk is gcc spotting this and going bananas. Fix this by simply using unsigned in to force all computations to use the well-defined unsigned behaviour.
Spotted by coverity.
--- drivers/gpu/drm/i2c/tda998x_drv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/i2c/tda998x_drv.c +1 -1
@@ -568,7 +568,7 @@ static irqreturn_t tda998x_irq_thread(int irq, void *data)static uint8_t tda998x_cksum (uint8_t *buf,size_t bytes) { -uint8_t sum =0 ; +unsigned sum =0 ;while (bytes--) sum += *buf++;
Signature · 1 line
1.8.5.2
Re: [PATCH 12/13] drm/i2c/tda998x: Fix signed overflow issue
Quoted 6 lines · Daniel Vetter
This is C standard hair-splitting, but afaict
- sum will be promoted to signed int in computation sinceuint8_tfits
- signed overflow is undefined.No we need to add up an awful lot of bytes to actually make it
^^
Now
Quoted 3 lines
overflow. But I guess the real risk is gcc spotting this and going bananas. Fix this by simply using unsigned in to force all computations to use the well-defined unsigned behaviour.
Seems reasonable... it also seems impossible (ha!) to break anything.
Quoted 24 lines
Spotted by coverity.
Cc Russell King <[email protected]>Cc Rob Clark <[email protected]>Cc Jean-Francois Moine <[email protected]>Signed-off-by Daniel Vetter <[email protected]>--- drivers/gpu/drm/i2c/tda998x_drv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/i2c/tda998x_drv.c +1
-1@@ -568,7 +568,7 @@ static irqreturn_t tda998x_irq_thread(int irq, void *data)static uint8_t tda998x_cksum (uint8_t *buf,size_t bytes) { -uint8_t sum =0 ; +unsigned sum =0 ;while (bytes--) sum += *buf++;
PATCH 13/13 drm: Fix error handling in drm_master_create
In reply to Daniel VetterWe need to check whether drm_ht_create succeed and clean up if not.
Spotted by coverity.
--- drivers/gpu/drm/drm_stub.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/drm_stub.c +4 -1
@@ -131,7 +131,10 @@ struct drm_master *drm_master_create(struct drm_minor *minor)kref_init (&master->refcount);spin_lock_init (&master->lock.spinlock);init_waitqueue_head (&master->lock.lock_queue); -drm_ht_create (&master->magiclist,DRM_MAGIC_HASH_ORDER ); +if (drm_ht_create (&master->magiclist,DRM_MAGIC_HASH_ORDER )) { +kfree (master); +return NULL ; + }INIT_LIST_HEAD (&master->magicfree); master->minor = minor;
Signature · 1 line
1.8.5.2