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]
Message-ID: <167fbc7a77db447d90f696666f6f0a9b@realtek.com>
Date:   Fri, 24 Nov 2023 08:51:15 +0000
From:   Ping-Ke Shih <pkshih@...ltek.com>
To:     Su Hui <suhui@...china.com>,
        "dan.carpenter@...aro.org" <dan.carpenter@...aro.org>,
        "kvalo@...nel.org" <kvalo@...nel.org>,
        "nathan@...nel.org" <nathan@...nel.org>,
        "ndesaulniers@...gle.com" <ndesaulniers@...gle.com>,
        "trix@...hat.com" <trix@...hat.com>
CC:     "lizetao1@...wei.com" <lizetao1@...wei.com>,
        "linville@...driver.com" <linville@...driver.com>,
        "Larry.Finger@...inger.net" <Larry.Finger@...inger.net>,
        "linux-wireless@...r.kernel.org" <linux-wireless@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "llvm@...ts.linux.dev" <llvm@...ts.linux.dev>,
        "kernel-janitors@...r.kernel.org" <kernel-janitors@...r.kernel.org>
Subject: RE: [PATCH v2 2/2] wifi: rtlwifi: rtl8821ae: phy: fix an undefined bitwise shift behavior



> -----Original Message-----
> From: Su Hui <suhui@...china.com>
> Sent: Friday, November 24, 2023 10:04 AM
> To: dan.carpenter@...aro.org; Ping-Ke Shih <pkshih@...ltek.com>; kvalo@...nel.org; nathan@...nel.org;
> ndesaulniers@...gle.com; trix@...hat.com
> Cc: Su Hui <suhui@...china.com>; lizetao1@...wei.com; linville@...driver.com; Larry.Finger@...inger.net;
> linux-wireless@...r.kernel.org; linux-kernel@...r.kernel.org; llvm@...ts.linux.dev;
> kernel-janitors@...r.kernel.org
> Subject: [PATCH v2 2/2] wifi: rtlwifi: rtl8821ae: phy: fix an undefined bitwise shift behavior
> 

[...]

> 
> diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/phy.c
> b/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/phy.c
> index 6df270e29e66..52ab1b0761c0 100644
> --- a/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/phy.c
> +++ b/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/phy.c
> @@ -31,7 +31,12 @@ static u32 _rtl8821ae_phy_calculate_bit_shift(u32 bitmask)
>  {
>         u32 i = ffs(bitmask);
> 
> -       return i ? i - 1 : 32;
> +       if (!i) {
> +               WARN_ON_ONCE(1);
> +               return 0;
> +       }
> +
> +       return i - 1;
>  }

Personally, I prefer to use __ffs(), because in normal case no need additional '-1',
and abnormal cases should not happen. 


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ