[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <dbe67fce55c6bbe569cefdc1a01708a0d01b140a.camel@perches.com>
Date: Sat, 03 Oct 2020 12:38:22 -0700
From: Joe Perches <joe@...ches.com>
To: Anant Thazhemadam <anant.thazhemadam@...il.com>
Cc: linux-kernel-mentees@...ts.linuxfoundation.org,
syzbot+abbc768b560c84d92fd3@...kaller.appspotmail.com,
Petko Manolov <petkan@...leusys.com>,
"David S. Miller" <davem@...emloft.net>,
Jakub Kicinski <kuba@...nel.org>, linux-usb@...r.kernel.org,
netdev@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [Linux-kernel-mentees][PATCH v2] net: usb: rtl8150: prevent
set_ethernet_addr from setting uninit address
On Thu, 2020-10-01 at 13:02 +0530, Anant Thazhemadam wrote:
> When get_registers() fails (which happens when usb_control_msg() fails)
> in set_ethernet_addr(), the uninitialized value of node_id gets copied
> as the address.
unrelated trivia:
> diff --git a/drivers/net/usb/rtl8150.c b/drivers/net/usb/rtl8150.c
[]
> @@ -274,12 +274,17 @@ static int write_mii_word(rtl8150_t * dev, u8 phy, __u8 indx, u16 reg)
> return 1;
> }
>
> -static inline void set_ethernet_addr(rtl8150_t * dev)
> +static bool set_ethernet_addr(rtl8150_t *dev)
> {
> u8 node_id[6];
This might be better as:
u8 node_id[ETH_ALEN];
> + int ret;
>
> - get_registers(dev, IDR, sizeof(node_id), node_id);
> - memcpy(dev->netdev->dev_addr, node_id, sizeof(node_id));
> + ret = get_registers(dev, IDR, sizeof(node_id), node_id);
> + if (ret == sizeof(node_id)) {
> + memcpy(dev->netdev->dev_addr, node_id, sizeof(node_id));
and
ether_addr_copy(dev->netdev->dev_addr, node_id);
Powered by blists - more mailing lists