mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Shuah Khan <skhan@linuxfoundation.org>
To: Greg KH <gregkh@linuxfoundation.org>
Cc: shuah@kernel.org, valentina.manea.m@gmail.com,
	linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
	Shuah Khan <skhan@linuxfoundation.org>
Subject: Re: [PATCH 1/2] usb/usbip: fix uninitialized variables errors
Date: Fri, 4 Nov 2022 09:18:13 -0600	[thread overview]
Message-ID: <e68cb73b-14ae-8c60-7fd6-f2aec4b6bfff@linuxfoundation.org> (raw)
In-Reply-To: <Y2PAd79kMEbt0HNf@kroah.com>

On 11/3/22 07:21, Greg KH wrote:
> On Thu, Nov 03, 2022 at 07:12:42AM -0600, Shuah Khan wrote:
>> Fix uninitialized variable errors reported by cppcheck. One example
>> below.
>>
>> usbip/stub_main.c:284:10: error: Uninitialized variables: priv.seqnum, priv.sdev, priv.urbs, priv.sgl, priv.num_urbs, priv.completed_urbs, priv.urb_status, priv.unlinking [uninitvar]
>>    return priv;
>>
>> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
>> ---
>>   drivers/usb/usbip/stub_main.c     | 2 +-
>>   drivers/usb/usbip/stub_rx.c       | 4 ++--
>>   drivers/usb/usbip/stub_tx.c       | 4 ++--
>>   drivers/usb/usbip/usbip_event.c   | 2 +-
>>   drivers/usb/usbip/vhci_hcd.c      | 2 +-
>>   drivers/usb/usbip/vhci_rx.c       | 2 +-
>>   drivers/usb/usbip/vhci_tx.c       | 4 ++--
>>   drivers/usb/usbip/vudc_dev.c      | 2 +-
>>   drivers/usb/usbip/vudc_rx.c       | 2 +-
>>   drivers/usb/usbip/vudc_transfer.c | 4 ++--
>>   10 files changed, 14 insertions(+), 14 deletions(-)
>>
>> diff --git a/drivers/usb/usbip/stub_main.c b/drivers/usb/usbip/stub_main.c
>> index e8c3131a8543..e1248b971218 100644
>> --- a/drivers/usb/usbip/stub_main.c
>> +++ b/drivers/usb/usbip/stub_main.c
>> @@ -277,7 +277,7 @@ static DRIVER_ATTR_WO(rebind);
>>   
>>   static struct stub_priv *stub_priv_pop_from_listhead(struct list_head *listhead)
>>   {
>> -	struct stub_priv *priv, *tmp;
>> +	struct stub_priv *priv = NULL, *tmp;
>>   
>>   	list_for_each_entry_safe(priv, tmp, listhead, list) {
> 
> cppcheck is wrong here, the code is fine, and setting priv to NULL does
> nothing.  If it was required, gcc would have hopefully caught it, and
> the code would have never worked :)
> 
> So are you sure all of these changes are really needed?  Last time I
> looked, cppcheck wasn't all that smart when it came to the kernel and
> threw up huge numbers of false-positives, like this one.
> 

You are right that this one is a false positive. I will take a close look at
the others in this patch.

thanks,
-- Shuah


  reply	other threads:[~2022-11-04 15:18 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-03 13:12 [PATCH 0/2] Fix uninit and signed integer overflow errors Shuah Khan
2022-11-03 13:12 ` [PATCH 1/2] usb/usbip: fix uninitialized variables errors Shuah Khan
2022-11-03 13:21   ` Greg KH
2022-11-04 15:18     ` Shuah Khan [this message]
2022-11-03 13:12 ` [PATCH 2/2] usb/usbip: Fix v_recv_cmd_submit() to use PIPE_BULK define Shuah Khan
2022-11-03 13:24   ` Greg KH
2022-11-04 15:19     ` Shuah Khan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e68cb73b-14ae-8c60-7fd6-f2aec4b6bfff@linuxfoundation.org \
    --to=skhan@linuxfoundation.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=shuah@kernel.org \
    --cc=valentina.manea.m@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®