lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20200210083243.GW1778@kadam>
Date:   Mon, 10 Feb 2020 11:32:43 +0300
From:   Dan Carpenter <dan.carpenter@...cle.com>
To:     Colin King <colin.king@...onical.com>
Cc:     Felipe Balbi <balbi@...nel.org>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        linux-usb@...r.kernel.org, kernel-janitors@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH] usb: dwc3: debug: remove redundant call to strlen

On Sat, Feb 08, 2020 at 04:25:08PM +0000, Colin King wrote:
> From: Colin Ian King <colin.king@...onical.com>
> 
> The call to strlen is redundant since the return value is assigned
> to variable len but not subsequently used. Remove the redundant
> call.
> 
> Addresses-Coverity: ("Unused value")
> Signed-off-by: Colin Ian King <colin.king@...onical.com>
> ---
>  drivers/usb/dwc3/debug.h | 2 --
>  1 file changed, 2 deletions(-)
> 
> diff --git a/drivers/usb/dwc3/debug.h b/drivers/usb/dwc3/debug.h
> index e56beb9d1e36..ee964352c8e2 100644
> --- a/drivers/usb/dwc3/debug.h
> +++ b/drivers/usb/dwc3/debug.h
> @@ -296,8 +296,6 @@ static inline const char *dwc3_ep_event_string(char *str, size_t size,
>  				status & DEPEVT_STATUS_TRANSFER_ACTIVE ?
>  				" (Active)" : " (Not Active)");
>  
> -		len = strlen(str);

This code is buggy.  It's a mixup between ret and len.  Get rid of "ret"
and use "len" throughout.

Unlike userspace snprintf() the kernel version always returns a positive
value.  It returns the number of bytes that would have been copied if
there were enough space.  This code should probably be changed to use
scnprintf() which returns the number of bytes which were copied
successfully.

The remove all the strlen() calls.  It should just be += the return.

	len += scnprintf(str + len, size - len, "Transfer Not Ready [%d] %s",
			 event->parameters,
			 status & DEPEVT_STATUS_TRANSFER_ACTIVE ?
				"(Active)" : "(Not Active)");

regards,
dan carpenter

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ