[PATCH net] net: usb: rtl8150 fix unintiatilzed variables in rtl8150_get_link_ksettings

Oliver Neukum posted 1 patch 1 year, 6 months ago
drivers/net/usb/rtl8150.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
[PATCH net] net: usb: rtl8150 fix unintiatilzed variables in rtl8150_get_link_ksettings
Posted by Oliver Neukum 1 year, 6 months ago
This functions retrieves values by passing a pointer. As the function
that retrieves them can fail before touching the pointers, the variables
must be initialized.

Reported-by: syzbot+5186630949e3c55f0799@syzkaller.appspotmail.com
Signed-off-by: Oliver Neukum <oneukum@suse.com>
---
 drivers/net/usb/rtl8150.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/usb/rtl8150.c b/drivers/net/usb/rtl8150.c
index 97afd7335d86..01a3b2417a54 100644
--- a/drivers/net/usb/rtl8150.c
+++ b/drivers/net/usb/rtl8150.c
@@ -778,7 +778,8 @@ static int rtl8150_get_link_ksettings(struct net_device *netdev,
 				      struct ethtool_link_ksettings *ecmd)
 {
 	rtl8150_t *dev = netdev_priv(netdev);
-	short lpa, bmcr;
+	short lpa = 0;
+	short bmcr = 0;
 	u32 supported;
 
 	supported = (SUPPORTED_10baseT_Half |
-- 
2.45.1
Re: [PATCH net] net: usb: rtl8150 fix unintiatilzed variables in rtl8150_get_link_ksettings
Posted by Petko Manolov 1 year, 6 months ago
On 24-06-19 15:28:03, Oliver Neukum wrote:
> This functions retrieves values by passing a pointer. As the function that
> retrieves them can fail before touching the pointers, the variables must be
> initialized.

ACK.


		Petko


> Reported-by: syzbot+5186630949e3c55f0799@syzkaller.appspotmail.com
> Signed-off-by: Oliver Neukum <oneukum@suse.com>
> ---
>  drivers/net/usb/rtl8150.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/usb/rtl8150.c b/drivers/net/usb/rtl8150.c
> index 97afd7335d86..01a3b2417a54 100644
> --- a/drivers/net/usb/rtl8150.c
> +++ b/drivers/net/usb/rtl8150.c
> @@ -778,7 +778,8 @@ static int rtl8150_get_link_ksettings(struct net_device *netdev,
>  				      struct ethtool_link_ksettings *ecmd)
>  {
>  	rtl8150_t *dev = netdev_priv(netdev);
> -	short lpa, bmcr;
> +	short lpa = 0;
> +	short bmcr = 0;
>  	u32 supported;
>  
>  	supported = (SUPPORTED_10baseT_Half |
> -- 
> 2.45.1
> 
>