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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 26 Jun 2018 20:29:52 +0300
From:   Andy Shevchenko <andy.shevchenko@...il.com>
To:     Michael Straube <straube.linux@...il.com>
Cc:     Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        devel@...verdev.osuosl.org,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        Joe Perches <joe@...ches.com>,
        Dan Carpenter <dan.carpenter@...cle.com>
Subject: Re: [PATCH v3 2/4] staging: rtl8723bs: refactor rtw_macaddr_cfg()

On Tue, Jun 26, 2018 at 11:14 AM, Michael Straube
<straube.linux@...il.com> wrote:
> Using is_broadcast_ether_addr() and is_zero_ether_addr() instead of
> testing each byte of the mac[] array for 0xff and 0x00 shortens the
> code and improves readability.
>
> If np == NULL, of_get_property() returns NULL, hence the "np" check
> is not needed.
>
> Instead of a fixed default mac address use a random one to reduce the
> likelihood of mac address collision.
>

> Thanks to Joe Perches and Dan Carpenter.

I guess you may use Suggested-by tag as well.

>
> Signed-off-by: Michael Straube <straube.linux@...il.com>
> ---
>  .../staging/rtl8723bs/core/rtw_ieee80211.c    | 19 ++++---------------
>  1 file changed, 4 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
> index e55895632921..7aa00d1391f7 100644
> --- a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
> +++ b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
> @@ -1177,24 +1177,13 @@ void rtw_macaddr_cfg(struct device *dev, u8 *mac_addr)
>                 memcpy(mac, mac_addr, ETH_ALEN);
>         }
>
> -       if (((mac[0] == 0xff) && (mac[1] == 0xff) && (mac[2] == 0xff) &&
> -            (mac[3] == 0xff) && (mac[4] == 0xff) && (mac[5] == 0xff)) ||
> -           ((mac[0] == 0x00) && (mac[1] == 0x00) && (mac[2] == 0x00) &&
> -            (mac[3] == 0x00) && (mac[4] == 0x00) && (mac[5] == 0x00))) {
> -               if (np &&
> -                   (addr = of_get_property(np, "local-mac-address", &len)) &&
> +       if (is_broadcast_ether_addr(mac) || is_zero_ether_addr(mac)) {
> +               if ((addr = of_get_property(np, "local-mac-address", &len)) &&
>                     len == ETH_ALEN) {
>                         memcpy(mac_addr, addr, ETH_ALEN);
>                 } else {
> -                       mac[0] = 0x00;
> -                       mac[1] = 0xe0;
> -                       mac[2] = 0x4c;
> -                       mac[3] = 0x87;
> -                       mac[4] = 0x00;
> -                       mac[5] = 0x00;
> -                       /*  use default mac addresss */
> -                       memcpy(mac_addr, mac, ETH_ALEN);
> -                       DBG_871X("MAC Address from efuse error, assign default one !!!\n");
> +                       eth_random_addr(mac_addr);
> +                       DBG_871X("MAC Address from efuse error, assign random one !!!\n");
>                 }
>         }
>
> --
> 2.18.0
>



-- 
With Best Regards,
Andy Shevchenko

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ