linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] kalmia: avoid potential uninitialized variable use
@ 2016-10-24 15:54 Arnd Bergmann
  2016-10-27 20:28 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Arnd Bergmann @ 2016-10-24 15:54 UTC (permalink / raw)
  To: netdev; +Cc: Arnd Bergmann, linux-usb, linux-kernel

The kalmia_send_init_packet() returns zero or a negative return
code, but gcc has no way of knowing that there cannot be a
positive return code, so it determines that copying the ethernet
address at the end of kalmia_bind() will access uninitialized
data:

drivers/net/usb/kalmia.c: In function ‘kalmia_bind’:
arch/x86/include/asm/string_32.h:78:22: error: ‘*((void *)&ethernet_addr+4)’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
   *((short *)to + 2) = *((short *)from + 2);
                      ^
drivers/net/usb/kalmia.c:138:5: note: ‘*((void *)&ethernet_addr+4)’ was declared here

This warning is harmless, but for consistency, we should make
the check for the return code match what the driver does everywhere
else and just progate it, which then gets rid of the warning.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/net/usb/kalmia.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/usb/kalmia.c b/drivers/net/usb/kalmia.c
index 5662babf0583..3e37724d30ae 100644
--- a/drivers/net/usb/kalmia.c
+++ b/drivers/net/usb/kalmia.c
@@ -151,7 +151,7 @@ kalmia_bind(struct usbnet *dev, struct usb_interface *intf)
 
 	status = kalmia_init_and_get_ethernet_addr(dev, ethernet_addr);
 
-	if (status < 0) {
+	if (status) {
 		usb_set_intfdata(intf, NULL);
 		usb_driver_release_interface(driver_of(intf), intf);
 		return status;
-- 
2.9.0

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

* Re: [PATCH] kalmia: avoid potential uninitialized variable use
  2016-10-24 15:54 [PATCH] kalmia: avoid potential uninitialized variable use Arnd Bergmann
@ 2016-10-27 20:28 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2016-10-27 20:28 UTC (permalink / raw)
  To: arnd; +Cc: netdev, linux-usb, linux-kernel

From: Arnd Bergmann <arnd@arndb.de>
Date: Mon, 24 Oct 2016 17:54:18 +0200

> The kalmia_send_init_packet() returns zero or a negative return
> code, but gcc has no way of knowing that there cannot be a
> positive return code, so it determines that copying the ethernet
> address at the end of kalmia_bind() will access uninitialized
> data:
> 
> drivers/net/usb/kalmia.c: In function ‘kalmia_bind’:
> arch/x86/include/asm/string_32.h:78:22: error: ‘*((void *)&ethernet_addr+4)’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
>    *((short *)to + 2) = *((short *)from + 2);
>                       ^
> drivers/net/usb/kalmia.c:138:5: note: ‘*((void *)&ethernet_addr+4)’ was declared here
> 
> This warning is harmless, but for consistency, we should make
> the check for the return code match what the driver does everywhere
> else and just progate it, which then gets rid of the warning.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Applied, thanks.

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

end of thread, other threads:[~2016-10-27 20:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-24 15:54 [PATCH] kalmia: avoid potential uninitialized variable use Arnd Bergmann
2016-10-27 20:28 ` David Miller

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).