All of lore.kernel.org
 help / color / mirror / Atom feed
* [patch] drm/amd/powerplay: fix a reversed condition
@ 2016-01-04 20:42 ` Dan Carpenter
  0 siblings, 0 replies; 10+ messages in thread
From: Dan Carpenter @ 2016-01-04 20:42 UTC (permalink / raw)
  To: David Airlie, Jammy Zhou
  Cc: Alex Deucher, kernel-janitors, Rex Zhu, dri-devel

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

Fixes: 4630f0faae80 ('drm/amd/powerplay: add Carrizo smu support')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.c b/drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.c
index e74023b..873a8d2 100644
--- a/drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.c
+++ b/drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.c
@@ -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,

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [patch] drm/amd/powerplay: fix a reversed condition
@ 2016-01-04 20:42 ` Dan Carpenter
  0 siblings, 0 replies; 10+ messages in thread
From: Dan Carpenter @ 2016-01-04 20:42 UTC (permalink / raw)
  To: David Airlie, Jammy Zhou
  Cc: Alex Deucher, kernel-janitors, Rex Zhu, dri-devel

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

Fixes: 4630f0faae80 ('drm/amd/powerplay: add Carrizo smu support')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.c b/drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.c
index e74023b..873a8d2 100644
--- a/drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.c
+++ b/drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.c
@@ -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
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [patch] drm/amd/powerplay: fix a reversed condition
  2016-01-04 20:42 ` Dan Carpenter
@ 2016-01-04 21:17   ` Alex Deucher
  -1 siblings, 0 replies; 10+ messages in thread
From: Alex Deucher @ 2016-01-04 21:17 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Jammy Zhou, kernel-janitors, Maling list - DRI developers,
	Alex Deucher, Rex Zhu

On Mon, Jan 4, 2016 at 3:42 PM, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> This test was reversed so it would end up leading to a NULL dereference.
>
> Fixes: 4630f0faae80 ('drm/amd/powerplay: add Carrizo smu support')
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Applied.  thanks!

Alex

>
> diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.c b/drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.c
> index e74023b..873a8d2 100644
> --- a/drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.c
> +++ b/drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.c
> @@ -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
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [patch] drm/amd/powerplay: fix a reversed condition
@ 2016-01-04 21:17   ` Alex Deucher
  0 siblings, 0 replies; 10+ messages in thread
From: Alex Deucher @ 2016-01-04 21:17 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Jammy Zhou, kernel-janitors, Maling list - DRI developers,
	Alex Deucher, Rex Zhu

On Mon, Jan 4, 2016 at 3:42 PM, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> This test was reversed so it would end up leading to a NULL dereference.
>
> Fixes: 4630f0faae80 ('drm/amd/powerplay: add Carrizo smu support')
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Applied.  thanks!

Alex

>
> diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.c b/drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.c
> index e74023b..873a8d2 100644
> --- a/drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.c
> +++ b/drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.c
> @@ -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
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [patch] drm/amd/powerplay: fix a reversed condition
  2016-01-04 20:42 ` Dan Carpenter
@ 2016-01-05  9:06   ` SF Markus Elfring
  -1 siblings, 0 replies; 10+ messages in thread
From: SF Markus Elfring @ 2016-01-05  9:06 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Jammy Zhou, kernel-janitors, dri-devel, Julia Lawall,
	Alex Deucher, Rex Zhu

> This test was reversed so it would end up leading to a NULL dereference.
> 
> Fixes: 4630f0faae80 ('drm/amd/powerplay: add Carrizo smu support')
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.c b/drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.c
> index e74023b..873a8d2 100644
> --- a/drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.c
> +++ b/drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.c
> @@ -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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [patch] drm/amd/powerplay: fix a reversed condition
@ 2016-01-05  9:06   ` SF Markus Elfring
  0 siblings, 0 replies; 10+ messages in thread
From: SF Markus Elfring @ 2016-01-05  9:06 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Jammy Zhou, kernel-janitors, dri-devel, Julia Lawall,
	Alex Deucher, Rex Zhu

> This test was reversed so it would end up leading to a NULL dereference.
> 
> Fixes: 4630f0faae80 ('drm/amd/powerplay: add Carrizo smu support')
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.c b/drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.c
> index e74023b..873a8d2 100644
> --- a/drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.c
> +++ b/drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.c
> @@ -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
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [patch] drm/amd/powerplay: fix a reversed condition
  2016-01-05  9:06   ` SF Markus Elfring
@ 2016-01-05 11:14     ` Dan Carpenter
  -1 siblings, 0 replies; 10+ messages in thread
From: Dan Carpenter @ 2016-01-05 11:14 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Jammy Zhou, kernel-janitors, dri-devel, Julia Lawall,
	Alex Deucher, Rex Zhu

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

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [patch] drm/amd/powerplay: fix a reversed condition
@ 2016-01-05 11:14     ` Dan Carpenter
  0 siblings, 0 replies; 10+ messages in thread
From: Dan Carpenter @ 2016-01-05 11:14 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Jammy Zhou, kernel-janitors, dri-devel, Julia Lawall,
	Alex Deucher, Rex Zhu

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

regards,
dan carpenter

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: drm/amd/powerplay: fix a reversed condition
  2016-01-05 11:14     ` Dan Carpenter
@ 2016-01-05 12:36       ` SF Markus Elfring
  -1 siblings, 0 replies; 10+ messages in thread
From: SF Markus Elfring @ 2016-01-05 12:36 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: David Airlie, Jammy Zhou, Alex Deucher, Rex Zhu, dri-devel,
	kernel-janitors, Julia Lawall

> 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?


> 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


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: drm/amd/powerplay: fix a reversed condition
@ 2016-01-05 12:36       ` SF Markus Elfring
  0 siblings, 0 replies; 10+ messages in thread
From: SF Markus Elfring @ 2016-01-05 12:36 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: David Airlie, Jammy Zhou, Alex Deucher, Rex Zhu, dri-devel,
	kernel-janitors, Julia Lawall

> 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?


> 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


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2016-01-05 12:36 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-04 20:42 [patch] drm/amd/powerplay: fix a reversed condition Dan Carpenter
2016-01-04 20:42 ` Dan Carpenter
2016-01-04 21:17 ` Alex Deucher
2016-01-04 21:17   ` Alex Deucher
2016-01-05  9:06 ` SF Markus Elfring
2016-01-05  9:06   ` SF Markus Elfring
2016-01-05 11:14   ` Dan Carpenter
2016-01-05 11:14     ` Dan Carpenter
2016-01-05 12:36     ` SF Markus Elfring
2016-01-05 12:36       ` SF Markus Elfring

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.