Skip to contentSkip to conversation

drm/amd/powerplay: fix a reversed condition

PATCH Applied Dan Carpenter 3 participants 5 messages Jan 4, 2016 – Jan 5, 2016

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

PATCH 1/1 drm/amd/powerplay: fix a reversed condition

This test was reversed so it would end up leading to a NULL dereference.

Fixes 4630f0faae80 ('drm/amd/powerplay: add Carrizo smu support')
drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.c +1 -1
index e74023b..873a8d2 100644
@@ -818,7 +818,7 @@ static int cz_smu_fini(struct pp_smumgr *smumgr)
 		return -EINVAL;
 
 	cz_smu = (struct cz_smumgr *)smumgr->backend;
-	if (!cz_smu) {
+	if (cz_smu) {
 		cgs_free_gpu_mem(smumgr->device,
 				cz_smu->toc_buffer.handle);
 		cgs_free_gpu_mem(smumgr->device,
Applied
#1 lore raw
Quoted 4 lines · Dan Carpenter

This test was reversed so it would end up leading to a NULL dereference.

Fixes 4630f0faae80 ('drm/amd/powerplay: add Carrizo smu support')

Applied. thanks!

Alex

Quoted 18 lines
drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.c +1 -1
index e74023b..873a8d2 100644
@@ -818,7 +818,7 @@ static int cz_smu_fini(struct pp_smumgr *smumgr)
                return -EINVAL;
 
        cz_smu = (struct cz_smumgr *)smumgr->backend;
-       if (!cz_smu) {
+       if (cz_smu) {
                cgs_free_gpu_mem(smumgr->device,
                                cz_smu->toc_buffer.handle);
                cgs_free_gpu_mem(smumgr->device,

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#2 lore raw
In reply to Dan Carpenter
Quoted 10 lines

This test was reversed so it would end up leading to a NULL dereference.

Fixes 4630f0faae80 ('drm/amd/powerplay: add Carrizo smu support')
drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.c +0 -0
index e74023b..873a8d2 100644

drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.c static int cz_smu_fini(struct pp_smumgr *smumgr) · line 824

Quoted 8 lines
drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.c +1 -1
@@ -818,7 +818,7 @@ static int cz_smu_fini(struct pp_smumgr *smumgr)
 		return -EINVAL;
 
 	cz_smu = (struct cz_smumgr *)smumgr->backend;
-	if (!cz_smu) {
+	if (cz_smu) {
 		cgs_free_gpu_mem(smumgr->device,
 				cz_smu->toc_buffer.handle);
 		cgs_free_gpu_mem(smumgr->device,

Was this issue found by an automatic static source code analysis of a tool like "Smatch"?
https://blogs.oracle.com/linuxkernel/entry/smatch_static_analysis_tool_overview
http://smatch.sourceforge.net/

Would it be useful to detect similar update candidates by the reuse of scripts for the semantic patch language?
How do you think about to get additional help and support from a software like Coccinelle for such search patterns?

Regards,
Markus

#3 lore raw

Yes. This was a Smatch warning but Coccinelle can also find this kinds of inconsistent NULL checking.

regards,
dan carpenter

#4 lore raw
Quoted 1 line

Yes. This was a Smatch warning

Thanks for this acknowledgement.

How do you think about to indicate such a detail more often in your update suggestions and bug reports?

Would it make sense to mark contributions from automatic static source code analysis by a dedicated tag in the commit message?

Quoted 1 line

but Coccinelle can also find this kinds of inconsistent NULL checking.

Should we try together to extend the script collection for the semantic patch language around such use cases?

Regards,
Markus