linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] usb: cdnsp: Useless condition has been removed
@ 2021-04-29  8:49 Pawel Laszczak
  2021-04-30  3:43 ` Peter Chen
  0 siblings, 1 reply; 5+ messages in thread
From: Pawel Laszczak @ 2021-04-29  8:49 UTC (permalink / raw)
  To: peter.chen; +Cc: gregkh, dan.carpenter, linux-usb, kurahul, Pawel Laszczak

From: Pawel Laszczak <pawell@cadence.com>

Patch removes the warning "variable dereferenced before
check 'pdev->dcbaa'" from cdnsp_mem_cleanup.

Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Pawel Laszczak <pawell@cadence.com>
---
 drivers/usb/cdns3/cdnsp-mem.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/cdns3/cdnsp-mem.c b/drivers/usb/cdns3/cdnsp-mem.c
index 5d4c4bfe15b7..a47948a1623f 100644
--- a/drivers/usb/cdns3/cdnsp-mem.c
+++ b/drivers/usb/cdns3/cdnsp-mem.c
@@ -1082,9 +1082,8 @@ void cdnsp_mem_cleanup(struct cdnsp_device *pdev)
 	dma_pool_destroy(pdev->device_pool);
 	pdev->device_pool = NULL;
 
-	if (pdev->dcbaa)
-		dma_free_coherent(dev, sizeof(*pdev->dcbaa),
-				  pdev->dcbaa, pdev->dcbaa->dma);
+	dma_free_coherent(dev, sizeof(*pdev->dcbaa),
+			  pdev->dcbaa, pdev->dcbaa->dma);
 
 	pdev->dcbaa = NULL;
 
-- 
2.25.1


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

* Re: [PATCH] usb: cdnsp: Useless condition has been removed
  2021-04-29  8:49 [PATCH] usb: cdnsp: Useless condition has been removed Pawel Laszczak
@ 2021-04-30  3:43 ` Peter Chen
  2021-04-30  4:52   ` Dan Carpenter
  0 siblings, 1 reply; 5+ messages in thread
From: Peter Chen @ 2021-04-30  3:43 UTC (permalink / raw)
  To: Pawel Laszczak; +Cc: gregkh, dan.carpenter, linux-usb, kurahul

On 21-04-29 10:49:14, Pawel Laszczak wrote:
> From: Pawel Laszczak <pawell@cadence.com>
> 
> Patch removes the warning "variable dereferenced before
> check 'pdev->dcbaa'" from cdnsp_mem_cleanup.

You may describe the real problem you fix, but not the warning
message from some auto build system.

> 
> Reported-by: kernel test robot <lkp@intel.com>
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> Signed-off-by: Pawel Laszczak <pawell@cadence.com>
> ---
>  drivers/usb/cdns3/cdnsp-mem.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/usb/cdns3/cdnsp-mem.c b/drivers/usb/cdns3/cdnsp-mem.c
> index 5d4c4bfe15b7..a47948a1623f 100644
> --- a/drivers/usb/cdns3/cdnsp-mem.c
> +++ b/drivers/usb/cdns3/cdnsp-mem.c
> @@ -1082,9 +1082,8 @@ void cdnsp_mem_cleanup(struct cdnsp_device *pdev)
>  	dma_pool_destroy(pdev->device_pool);
>  	pdev->device_pool = NULL;
>  
> -	if (pdev->dcbaa)
> -		dma_free_coherent(dev, sizeof(*pdev->dcbaa),
> -				  pdev->dcbaa, pdev->dcbaa->dma);
> +	dma_free_coherent(dev, sizeof(*pdev->dcbaa),
> +			  pdev->dcbaa, pdev->dcbaa->dma);
>  
>  	pdev->dcbaa = NULL;
>  
> -- 
> 2.25.1
> 

-- 

Thanks,
Peter Chen


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

* Re: [PATCH] usb: cdnsp: Useless condition has been removed
  2021-04-30  3:43 ` Peter Chen
@ 2021-04-30  4:52   ` Dan Carpenter
  2021-04-30  7:11     ` Peter Chen
  0 siblings, 1 reply; 5+ messages in thread
From: Dan Carpenter @ 2021-04-30  4:52 UTC (permalink / raw)
  To: Peter Chen; +Cc: Pawel Laszczak, gregkh, linux-usb, kurahul

On Fri, Apr 30, 2021 at 11:43:49AM +0800, Peter Chen wrote:
> On 21-04-29 10:49:14, Pawel Laszczak wrote:
> > From: Pawel Laszczak <pawell@cadence.com>
> > 
> > Patch removes the warning "variable dereferenced before
> > check 'pdev->dcbaa'" from cdnsp_mem_cleanup.
> 
> You may describe the real problem you fix, but not the warning
> message from some auto build system.
> 

I really feel people have become too lost in the weeds of what matters
and what does not.  For internships, people want picky feedback in case
they're forced to deal with the ultra drill sargent maintainers.  But
really the important thing in a commit message is if you can understand
the problem and the fix.  In this case everyone who is capable of
understanding the patch can understand the commit message.

Also if you're going to criticize someone's commit message then just
write it the way you want so they can copy and paste.  I had someone
yesterday say that my commit message where I deleted a NULL check and
related dead code was not clear enough that the behavior was
"intentional" and I took that to mean that they wanted me to say that
deleting the dead code did not change runtime behavior.  I'm still not
sure that's what they wanted me to add...  The point is no one can read
your mind, if you want a commit message to say something specific then
just say it instead of hinting around the bush and we have to send a v2
and v3 commit message.

regards,
dan carpenter


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

* Re: [PATCH] usb: cdnsp: Useless condition has been removed
  2021-04-30  4:52   ` Dan Carpenter
@ 2021-04-30  7:11     ` Peter Chen
  2021-04-30 11:51       ` Dan Carpenter
  0 siblings, 1 reply; 5+ messages in thread
From: Peter Chen @ 2021-04-30  7:11 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: Pawel Laszczak, gregkh, linux-usb, kurahul

On 21-04-30 07:52:48, Dan Carpenter wrote:
> On Fri, Apr 30, 2021 at 11:43:49AM +0800, Peter Chen wrote:
> > On 21-04-29 10:49:14, Pawel Laszczak wrote:
> > > From: Pawel Laszczak <pawell@cadence.com>
> > > 
> > > Patch removes the warning "variable dereferenced before
> > > check 'pdev->dcbaa'" from cdnsp_mem_cleanup.
> > 
> > You may describe the real problem you fix, but not the warning
> > message from some auto build system.
> > 
> 
> I really feel people have become too lost in the weeds of what matters
> and what does not.  For internships, people want picky feedback in case
> they're forced to deal with the ultra drill sargent maintainers.  But
> really the important thing in a commit message is if you can understand
> the problem and the fix.  In this case everyone who is capable of
> understanding the patch can understand the commit message.
> 
> Also if you're going to criticize someone's commit message then just
> write it the way you want so they can copy and paste.  I had someone
> yesterday say that my commit message where I deleted a NULL check and
> related dead code was not clear enough that the behavior was
> "intentional" and I took that to mean that they wanted me to say that
> deleting the dead code did not change runtime behavior.  I'm still not
> sure that's what they wanted me to add...  The point is no one can read
> your mind, if you want a commit message to say something specific then
> just say it instead of hinting around the bush and we have to send a v2
> and v3 commit message.
> 
> regards,
> dan carpenter

Hi Dan,

Thanks for your comments, it's the good suggestion. But everyone may have
slight different criteria that what's really clear.

For this patch, I don't understand the commits, the pdev->dcbaa is set as
NULL after dma_free_coherent, why it has this warning.

-- 

Thanks,
Peter Chen


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

* Re: [PATCH] usb: cdnsp: Useless condition has been removed
  2021-04-30  7:11     ` Peter Chen
@ 2021-04-30 11:51       ` Dan Carpenter
  0 siblings, 0 replies; 5+ messages in thread
From: Dan Carpenter @ 2021-04-30 11:51 UTC (permalink / raw)
  To: Peter Chen; +Cc: Pawel Laszczak, gregkh, linux-usb, kurahul

On Fri, Apr 30, 2021 at 03:11:45PM +0800, Peter Chen wrote:
> On 21-04-30 07:52:48, Dan Carpenter wrote:
> > On Fri, Apr 30, 2021 at 11:43:49AM +0800, Peter Chen wrote:
> > > On 21-04-29 10:49:14, Pawel Laszczak wrote:
> > > > From: Pawel Laszczak <pawell@cadence.com>
> > > > 
> > > > Patch removes the warning "variable dereferenced before
> > > > check 'pdev->dcbaa'" from cdnsp_mem_cleanup.
> > > 
> > > You may describe the real problem you fix, but not the warning
> > > message from some auto build system.
> > > 
> > 
> > I really feel people have become too lost in the weeds of what matters
> > and what does not.  For internships, people want picky feedback in case
> > they're forced to deal with the ultra drill sargent maintainers.  But
> > really the important thing in a commit message is if you can understand
> > the problem and the fix.  In this case everyone who is capable of
> > understanding the patch can understand the commit message.
> > 
> > Also if you're going to criticize someone's commit message then just
> > write it the way you want so they can copy and paste.  I had someone
> > yesterday say that my commit message where I deleted a NULL check and
> > related dead code was not clear enough that the behavior was
> > "intentional" and I took that to mean that they wanted me to say that
> > deleting the dead code did not change runtime behavior.  I'm still not
> > sure that's what they wanted me to add...  The point is no one can read
> > your mind, if you want a commit message to say something specific then
> > just say it instead of hinting around the bush and we have to send a v2
> > and v3 commit message.
> > 
> > regards,
> > dan carpenter
> 
> Hi Dan,
> 
> Thanks for your comments, it's the good suggestion. But everyone may have
> slight different criteria that what's really clear.
> 
> For this patch, I don't understand the commits, the pdev->dcbaa is set as
> NULL after dma_free_coherent, why it has this warning.
> 

Hm...  I guess it's a fair point that it's not clear to the reviewer
where the unchecked dereference happens.  Here is how I would write that
commit.

    This code generates a Smatch warning:

    drivers/usb/cdns3/cdnsp-mem.c:1085 cdnsp_mem_cleanup()
    warn: variable dereferenced before check 'pdev->dcbaa' (see line 1067)

    The unchecked dereference happens inside the function when we call:

    	cdnsp_free_priv_device(pdev);

    But fortunately, the "pdev->dcbaa" pointer can never be NULL so it
    does not lead to a runtime issue.  We can just remove the NULL check
    which silences the warning and makes the code consistent.

regards,
dan carpenter


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

end of thread, other threads:[~2021-04-30 11:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-29  8:49 [PATCH] usb: cdnsp: Useless condition has been removed Pawel Laszczak
2021-04-30  3:43 ` Peter Chen
2021-04-30  4:52   ` Dan Carpenter
2021-04-30  7:11     ` Peter Chen
2021-04-30 11:51       ` Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).