* [PATCH] rtw88: don't treat NULL pointer as an array
@ 2020-08-21 21:17 Brian Norris
2020-08-24 1:50 ` Tony Chuang
2020-08-27 10:04 ` Kalle Valo
0 siblings, 2 replies; 3+ messages in thread
From: Brian Norris @ 2020-08-21 21:17 UTC (permalink / raw)
To: linux-wireless; +Cc: Yan-Hsuan Chuang, Brian Norris
I'm not a standards expert, but this really looks to be undefined
behavior, when chip->dig_cck may be NULL. (And, we're trying to do a
NULL check a few lines down, because some chip variants will use NULL.)
Fixes: fc637a860a82 ("rtw88: 8723d: Set IG register for CCK rate")
Signed-off-by: Brian Norris <briannorris@chromium.org>
---
drivers/net/wireless/realtek/rtw88/phy.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/net/wireless/realtek/rtw88/phy.c b/drivers/net/wireless/realtek/rtw88/phy.c
index 8d93f3159746..9687b376d221 100644
--- a/drivers/net/wireless/realtek/rtw88/phy.c
+++ b/drivers/net/wireless/realtek/rtw88/phy.c
@@ -147,12 +147,13 @@ void rtw_phy_dig_write(struct rtw_dev *rtwdev, u8 igi)
{
struct rtw_chip_info *chip = rtwdev->chip;
struct rtw_hal *hal = &rtwdev->hal;
- const struct rtw_hw_reg *dig_cck = &chip->dig_cck[0];
u32 addr, mask;
u8 path;
- if (dig_cck)
+ if (chip->dig_cck) {
+ const struct rtw_hw_reg *dig_cck = &chip->dig_cck[0];
rtw_write32_mask(rtwdev, dig_cck->addr, dig_cck->mask, igi >> 1);
+ }
for (path = 0; path < hal->rf_path_num; path++) {
addr = chip->dig[path].addr;
--
2.28.0.297.g1956fa8f8d-goog
^ permalink raw reply related [flat|nested] 3+ messages in thread
* RE: [PATCH] rtw88: don't treat NULL pointer as an array
2020-08-21 21:17 [PATCH] rtw88: don't treat NULL pointer as an array Brian Norris
@ 2020-08-24 1:50 ` Tony Chuang
2020-08-27 10:04 ` Kalle Valo
1 sibling, 0 replies; 3+ messages in thread
From: Tony Chuang @ 2020-08-24 1:50 UTC (permalink / raw)
To: Brian Norris, linux-wireless
>
> I'm not a standards expert, but this really looks to be undefined
> behavior, when chip->dig_cck may be NULL. (And, we're trying to do a
> NULL check a few lines down, because some chip variants will use NULL.)
>
> Fixes: fc637a860a82 ("rtw88: 8723d: Set IG register for CCK rate")
Acked-by: Yan-Hsuan Chuang <yhchuang@realtek.com>
> Signed-off-by: Brian Norris <briannorris@chromium.org>
> ---
> drivers/net/wireless/realtek/rtw88/phy.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/wireless/realtek/rtw88/phy.c
> b/drivers/net/wireless/realtek/rtw88/phy.c
> index 8d93f3159746..9687b376d221 100644
> --- a/drivers/net/wireless/realtek/rtw88/phy.c
> +++ b/drivers/net/wireless/realtek/rtw88/phy.c
> @@ -147,12 +147,13 @@ void rtw_phy_dig_write(struct rtw_dev *rtwdev, u8
> igi)
> {
> struct rtw_chip_info *chip = rtwdev->chip;
> struct rtw_hal *hal = &rtwdev->hal;
> - const struct rtw_hw_reg *dig_cck = &chip->dig_cck[0];
> u32 addr, mask;
> u8 path;
>
> - if (dig_cck)
> + if (chip->dig_cck) {
> + const struct rtw_hw_reg *dig_cck = &chip->dig_cck[0];
> rtw_write32_mask(rtwdev, dig_cck->addr, dig_cck->mask, igi >> 1);
> + }
>
> for (path = 0; path < hal->rf_path_num; path++) {
> addr = chip->dig[path].addr;
Thanks.
Yen-Hsuan
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] rtw88: don't treat NULL pointer as an array
2020-08-21 21:17 [PATCH] rtw88: don't treat NULL pointer as an array Brian Norris
2020-08-24 1:50 ` Tony Chuang
@ 2020-08-27 10:04 ` Kalle Valo
1 sibling, 0 replies; 3+ messages in thread
From: Kalle Valo @ 2020-08-27 10:04 UTC (permalink / raw)
To: Brian Norris; +Cc: linux-wireless, Yan-Hsuan Chuang, Brian Norris
Brian Norris <briannorris@chromium.org> wrote:
> I'm not a standards expert, but this really looks to be undefined
> behavior, when chip->dig_cck may be NULL. (And, we're trying to do a
> NULL check a few lines down, because some chip variants will use NULL.)
>
> Fixes: fc637a860a82 ("rtw88: 8723d: Set IG register for CCK rate")
> Signed-off-by: Brian Norris <briannorris@chromium.org>
> Acked-by: Yan-Hsuan Chuang <yhchuang@realtek.com>
Patch applied to wireless-drivers-next.git, thanks.
22b726cbdd09 rtw88: don't treat NULL pointer as an array
--
https://patchwork.kernel.org/patch/11730581/
https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-08-27 10:04 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-21 21:17 [PATCH] rtw88: don't treat NULL pointer as an array Brian Norris
2020-08-24 1:50 ` Tony Chuang
2020-08-27 10:04 ` Kalle Valo
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).