Message ID | 20231102003716.25815-1-pkshih@realtek.com |
---|---|
State | New |
Headers | show |
Series | wifi: rtw89: coex: use struct assignment to replace memcpy() to append TDMA content | expand |
Ping-Ke Shih <pkshih@realtek.com> wrote: > To notify firmware TDMA timeslot assignment, append TDMA parameters when > sending policy H2C firmware command. However, compiler warns we do memcpy() > data to val[] field of TLV struct. To avoid this, assign the struct value > with simple '=' instead. Compile tested only. > > rtw89/coex.c: In function '_append_tdma': > drivers/net/wireless/realtek/rtw89/coex.c:1585:17: > warning: writing 8 bytes into a region of size 0 [-Wstringop-overflow=] > 1585 | memcpy(&v3->tdma, &dm->tdma, sizeof(v3->tdma)); > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > In file included from drivers/net/wireless/realtek/rtw89/coex.h:8, > from drivers/net/wireless/realtek/rtw89/coex.c:5: > drivers/net/wireless/realtek/rtw89/core.h:2703:37: > note: at offset [5714, 71249] into destination object 'ver' of size 8 > 2703 | const struct rtw89_btc_ver *ver; > | ^~~ > drivers/net/wireless/realtek/rtw89/coex.c:1579:17: > warning: writing 8 bytes into a region of size 0 [-Wstringop-overflow=] > 1579 | memcpy(v, &dm->tdma, sizeof(*v)); > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > drivers/net/wireless/realtek/rtw89/core.h:2703:37: > note: at offset [5710, 71245] into destination object 'ver' of size 8 > 2703 | const struct rtw89_btc_ver *ver; > | ^~~ > > Reported-by: kernel test robot <lkp@intel.com> > Closes: https://lore.kernel.org/oe-kbuild-all/202310301908.Wrj0diqe-lkp@intel.com/ > Signed-off-by: Ping-Ke Shih <pkshih@realtek.com> Patch applied to wireless-next.git, thanks. ca76817f4c4b wifi: rtw89: coex: use struct assignment to replace memcpy() to append TDMA content
diff --git a/drivers/net/wireless/realtek/rtw89/coex.c b/drivers/net/wireless/realtek/rtw89/coex.c index bdcc172639e4..b842cd9a86f8 100644 --- a/drivers/net/wireless/realtek/rtw89/coex.c +++ b/drivers/net/wireless/realtek/rtw89/coex.c @@ -1576,13 +1576,13 @@ static void _append_tdma(struct rtw89_dev *rtwdev) if (ver->fcxtdma == 1) { v = (struct rtw89_btc_fbtc_tdma *)&tlv->val[0]; tlv->len = sizeof(*v); - memcpy(v, &dm->tdma, sizeof(*v)); + *v = dm->tdma; btc->policy_len += BTC_TLV_HDR_LEN + sizeof(*v); } else { tlv->len = sizeof(*v3); v3 = (struct rtw89_btc_fbtc_tdma_v3 *)&tlv->val[0]; v3->fver = ver->fcxtdma; - memcpy(&v3->tdma, &dm->tdma, sizeof(v3->tdma)); + v3->tdma = dm->tdma; btc->policy_len += BTC_TLV_HDR_LEN + sizeof(*v3); }
To notify firmware TDMA timeslot assignment, append TDMA parameters when sending policy H2C firmware command. However, compiler warns we do memcpy() data to val[] field of TLV struct. To avoid this, assign the struct value with simple '=' instead. Compile tested only. rtw89/coex.c: In function '_append_tdma': drivers/net/wireless/realtek/rtw89/coex.c:1585:17: warning: writing 8 bytes into a region of size 0 [-Wstringop-overflow=] 1585 | memcpy(&v3->tdma, &dm->tdma, sizeof(v3->tdma)); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from drivers/net/wireless/realtek/rtw89/coex.h:8, from drivers/net/wireless/realtek/rtw89/coex.c:5: drivers/net/wireless/realtek/rtw89/core.h:2703:37: note: at offset [5714, 71249] into destination object 'ver' of size 8 2703 | const struct rtw89_btc_ver *ver; | ^~~ drivers/net/wireless/realtek/rtw89/coex.c:1579:17: warning: writing 8 bytes into a region of size 0 [-Wstringop-overflow=] 1579 | memcpy(v, &dm->tdma, sizeof(*v)); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/net/wireless/realtek/rtw89/core.h:2703:37: note: at offset [5710, 71245] into destination object 'ver' of size 8 2703 | const struct rtw89_btc_ver *ver; | ^~~ Reported-by: kernel test robot <lkp@intel.com> Closes: https://lore.kernel.org/oe-kbuild-all/202310301908.Wrj0diqe-lkp@intel.com/ Signed-off-by: Ping-Ke Shih <pkshih@realtek.com> --- drivers/net/wireless/realtek/rtw89/coex.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)