netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: lan78xx: Fix possible uninit bug
@ 2023-07-05  1:15 Yu Hao
  2023-07-05  6:15 ` Herve Codina
  2023-07-05  7:16 ` Greg KH
  0 siblings, 2 replies; 3+ messages in thread
From: Yu Hao @ 2023-07-05  1:15 UTC (permalink / raw)
  To: woojung.huh, UNGLinuxDriver, davem, edumazet, kuba, pabeni,
	netdev, linux-usb, linux-kernel

The variable buf should be initialized in the function lan78xx_read_reg.
However, there is no return value check, which means the variable buf
could still be uninit. But there is a read later.

Signed-off-by: Yu Hao <yhao016@ucr.edu>
---
 drivers/net/usb/lan78xx.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c
index c458c030fadf..4c9318c92fe6 100644
--- a/drivers/net/usb/lan78xx.c
+++ b/drivers/net/usb/lan78xx.c
@@ -1091,8 +1091,11 @@ static int lan78xx_write_raw_otp(struct
lan78xx_net *dev, u32 offset,
    int i;
    u32 buf;
    unsigned long timeout;
+   int ret;

-   lan78xx_read_reg(dev, OTP_PWR_DN, &buf);
+   ret = lan78xx_read_reg(dev, OTP_PWR_DN, &buf);
+   if (ret < 0)
+       return ret;

    if (buf & OTP_PWR_DN_PWRDN_N_) {
        /* clear it and wait to be cleared */
-- 
2.34.1

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

* Re: [PATCH] net: lan78xx: Fix possible uninit bug
  2023-07-05  1:15 [PATCH] net: lan78xx: Fix possible uninit bug Yu Hao
@ 2023-07-05  6:15 ` Herve Codina
  2023-07-05  7:16 ` Greg KH
  1 sibling, 0 replies; 3+ messages in thread
From: Herve Codina @ 2023-07-05  6:15 UTC (permalink / raw)
  To: Yu Hao
  Cc: woojung.huh, UNGLinuxDriver, davem, edumazet, kuba, pabeni,
	netdev, linux-usb, linux-kernel

On Tue, 4 Jul 2023 18:15:09 -0700
Yu Hao <yhao016@ucr.edu> wrote:

> The variable buf should be initialized in the function lan78xx_read_reg.
> However, there is no return value check, which means the variable buf
> could still be uninit. But there is a read later.
> 
> Signed-off-by: Yu Hao <yhao016@ucr.edu>
> ---
>  drivers/net/usb/lan78xx.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c
> index c458c030fadf..4c9318c92fe6 100644
> --- a/drivers/net/usb/lan78xx.c
> +++ b/drivers/net/usb/lan78xx.c
> @@ -1091,8 +1091,11 @@ static int lan78xx_write_raw_otp(struct
> lan78xx_net *dev, u32 offset,
>     int i;
>     u32 buf;
>     unsigned long timeout;
> +   int ret;
> 
> -   lan78xx_read_reg(dev, OTP_PWR_DN, &buf);
> +   ret = lan78xx_read_reg(dev, OTP_PWR_DN, &buf);
> +   if (ret < 0)
> +       return ret;
> 
>     if (buf & OTP_PWR_DN_PWRDN_N_) {
>         /* clear it and wait to be cleared */

Reviewed-by: Herve Codina <herve.codina@bootlin.com>

Best regards,
Hervé

-- 
Hervé Codina, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

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

* Re: [PATCH] net: lan78xx: Fix possible uninit bug
  2023-07-05  1:15 [PATCH] net: lan78xx: Fix possible uninit bug Yu Hao
  2023-07-05  6:15 ` Herve Codina
@ 2023-07-05  7:16 ` Greg KH
  1 sibling, 0 replies; 3+ messages in thread
From: Greg KH @ 2023-07-05  7:16 UTC (permalink / raw)
  To: Yu Hao
  Cc: woojung.huh, UNGLinuxDriver, davem, edumazet, kuba, pabeni,
	netdev, linux-usb, linux-kernel

On Tue, Jul 04, 2023 at 06:15:09PM -0700, Yu Hao wrote:
> The variable buf should be initialized in the function lan78xx_read_reg.
> However, there is no return value check, which means the variable buf
> could still be uninit. But there is a read later.
> 
> Signed-off-by: Yu Hao <yhao016@ucr.edu>
> ---
>  drivers/net/usb/lan78xx.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c
> index c458c030fadf..4c9318c92fe6 100644
> --- a/drivers/net/usb/lan78xx.c
> +++ b/drivers/net/usb/lan78xx.c
> @@ -1091,8 +1091,11 @@ static int lan78xx_write_raw_otp(struct
> lan78xx_net *dev, u32 offset,
>     int i;
>     u32 buf;
>     unsigned long timeout;
> +   int ret;
> 
> -   lan78xx_read_reg(dev, OTP_PWR_DN, &buf);
> +   ret = lan78xx_read_reg(dev, OTP_PWR_DN, &buf);
> +   if (ret < 0)
> +       return ret;
> 
>     if (buf & OTP_PWR_DN_PWRDN_N_) {
>         /* clear it and wait to be cleared */
> -- 
> 2.34.1

Hi,

This is the friendly patch-bot of Greg Kroah-Hartman.  You have sent him
a patch that has triggered this response.  He used to manually respond
to these common problems, but in order to save his sanity (he kept
writing the same thing over and over, yet to different people), I was
created.  Hopefully you will not take offence and will fix the problem
in your patch and resubmit it so that it can be accepted into the Linux
kernel tree.

You are receiving this message because of the following common error(s)
as indicated below:

- Your patch is malformed (tabs converted to spaces, linewrapped, etc.)
  and can not be applied.  Please read the file,
  Documentation/process/email-clients.rst in order to fix this.

If you wish to discuss this problem further, or you have questions about
how to resolve this issue, please feel free to respond to this email and
Greg will reply once he has dug out from the pending patches received
from other developers.

thanks,

greg k-h's patch email bot

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

end of thread, other threads:[~2023-07-05  7:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-05  1:15 [PATCH] net: lan78xx: Fix possible uninit bug Yu Hao
2023-07-05  6:15 ` Herve Codina
2023-07-05  7:16 ` Greg KH

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