2022-04-22 17:25:01

by Dan Carpenter

[permalink] [raw]
Subject: [ammarfaizi2-block:kvalo/ath/pending 36/40] drivers/net/wireless/ath/ath11k/mac.c:8293 ath11k_mac_op_set_bios_sar_specs() warn: variable dereferenced before check 'sar' (see line 8280)

tree: https://github.com/ammarfaizi2/linux-block kvalo/ath/pending
head: c9a8efc35304a89fc0751649945909caf03eeb29
commit: 5ad5b356e75f402fec930cf0d77b6c7862850b55 [36/40] ath11k: Add support for SAR
config: x86_64-randconfig-m001-20220418 (https://download.01.org/0day-ci/archive/20220418/[email protected]/config)
compiler: gcc-11 (Debian 11.2.0-19) 11.2.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <[email protected]>
Reported-by: Dan Carpenter <[email protected]>

New smatch warnings:
drivers/net/wireless/ath/ath11k/mac.c:8293 ath11k_mac_op_set_bios_sar_specs() warn: variable dereferenced before check 'sar' (see line 8280)

vim +/sar +8293 drivers/net/wireless/ath/ath11k/mac.c

5ad5b356e75f40 Baochen Qiang 2022-04-12 8276 static int ath11k_mac_op_set_bios_sar_specs(struct ieee80211_hw *hw,
5ad5b356e75f40 Baochen Qiang 2022-04-12 8277 const struct cfg80211_sar_specs *sar)
5ad5b356e75f40 Baochen Qiang 2022-04-12 8278 {
5ad5b356e75f40 Baochen Qiang 2022-04-12 8279 struct ath11k *ar = hw->priv;
5ad5b356e75f40 Baochen Qiang 2022-04-12 @8280 const struct cfg80211_sar_sub_specs *sspec = sar->sub_specs;
^^^^^^^^^^^^^^
Dereference

5ad5b356e75f40 Baochen Qiang 2022-04-12 8281 int ret, index;
5ad5b356e75f40 Baochen Qiang 2022-04-12 8282 u8 *sar_tbl;
5ad5b356e75f40 Baochen Qiang 2022-04-12 8283 u32 i;
5ad5b356e75f40 Baochen Qiang 2022-04-12 8284
5ad5b356e75f40 Baochen Qiang 2022-04-12 8285 mutex_lock(&ar->conf_mutex);
5ad5b356e75f40 Baochen Qiang 2022-04-12 8286
5ad5b356e75f40 Baochen Qiang 2022-04-12 8287 if (!test_bit(WMI_TLV_SERVICE_BIOS_SAR_SUPPORT, ar->ab->wmi_ab.svc_map) ||
5ad5b356e75f40 Baochen Qiang 2022-04-12 8288 !ar->ab->hw_params.bios_sar_capa) {
5ad5b356e75f40 Baochen Qiang 2022-04-12 8289 ret = -EOPNOTSUPP;
5ad5b356e75f40 Baochen Qiang 2022-04-12 8290 goto exit;
5ad5b356e75f40 Baochen Qiang 2022-04-12 8291 }
5ad5b356e75f40 Baochen Qiang 2022-04-12 8292
5ad5b356e75f40 Baochen Qiang 2022-04-12 @8293 if (!sar || sar->type != NL80211_SAR_TYPE_POWER ||
^^^
Checked too late

5ad5b356e75f40 Baochen Qiang 2022-04-12 8294 sar->num_sub_specs == 0) {
5ad5b356e75f40 Baochen Qiang 2022-04-12 8295 ret = -EINVAL;
5ad5b356e75f40 Baochen Qiang 2022-04-12 8296 goto exit;
5ad5b356e75f40 Baochen Qiang 2022-04-12 8297 }
5ad5b356e75f40 Baochen Qiang 2022-04-12 8298
5ad5b356e75f40 Baochen Qiang 2022-04-12 8299 ret = ath11k_wmi_pdev_set_bios_geo_table_param(ar);
5ad5b356e75f40 Baochen Qiang 2022-04-12 8300 if (ret) {
5ad5b356e75f40 Baochen Qiang 2022-04-12 8301 ath11k_warn(ar->ab, "failed to set geo table: %d\n", ret);
5ad5b356e75f40 Baochen Qiang 2022-04-12 8302 goto exit;
5ad5b356e75f40 Baochen Qiang 2022-04-12 8303 }
5ad5b356e75f40 Baochen Qiang 2022-04-12 8304

--
0-DAY CI Kernel Test Service
https://01.org/lkp


2022-04-27 11:54:17

by Kalle Valo

[permalink] [raw]
Subject: Re: [ammarfaizi2-block:kvalo/ath/pending 36/40] drivers/net/wireless/ath/ath11k/mac.c:8293 ath11k_mac_op_set_bios_sar_specs() warn: variable dereferenced before check 'sar' (see line 8280)

+ ath11k list

Dan Carpenter <[email protected]> writes:

> tree: https://github.com/ammarfaizi2/linux-block kvalo/ath/pending
> head: c9a8efc35304a89fc0751649945909caf03eeb29
> commit: 5ad5b356e75f402fec930cf0d77b6c7862850b55 [36/40] ath11k: Add support for SAR
> config: x86_64-randconfig-m001-20220418 (https://download.01.org/0day-ci/archive/20220418/[email protected]/config)
> compiler: gcc-11 (Debian 11.2.0-19) 11.2.0
>
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot <[email protected]>
> Reported-by: Dan Carpenter <[email protected]>
>
> New smatch warnings:
> drivers/net/wireless/ath/ath11k/mac.c:8293 ath11k_mac_op_set_bios_sar_specs() warn: variable dereferenced before check 'sar' (see line 8280)
>
> vim +/sar +8293 drivers/net/wireless/ath/ath11k/mac.c
>
> 5ad5b356e75f40 Baochen Qiang 2022-04-12 8276 static int ath11k_mac_op_set_bios_sar_specs(struct ieee80211_hw *hw,
> 5ad5b356e75f40 Baochen Qiang 2022-04-12 8277 const struct cfg80211_sar_specs *sar)
> 5ad5b356e75f40 Baochen Qiang 2022-04-12 8278 {
> 5ad5b356e75f40 Baochen Qiang 2022-04-12 8279 struct ath11k *ar = hw->priv;
> 5ad5b356e75f40 Baochen Qiang 2022-04-12 @8280 const struct cfg80211_sar_sub_specs *sspec = sar->sub_specs;
> ^^^^^^^^^^^^^^
> Dereference
>
> 5ad5b356e75f40 Baochen Qiang 2022-04-12 8281 int ret, index;
> 5ad5b356e75f40 Baochen Qiang 2022-04-12 8282 u8 *sar_tbl;
> 5ad5b356e75f40 Baochen Qiang 2022-04-12 8283 u32 i;
> 5ad5b356e75f40 Baochen Qiang 2022-04-12 8284
> 5ad5b356e75f40 Baochen Qiang 2022-04-12 8285 mutex_lock(&ar->conf_mutex);
> 5ad5b356e75f40 Baochen Qiang 2022-04-12 8286
> 5ad5b356e75f40 Baochen Qiang 2022-04-12 8287 if (!test_bit(WMI_TLV_SERVICE_BIOS_SAR_SUPPORT, ar->ab->wmi_ab.svc_map) ||
> 5ad5b356e75f40 Baochen Qiang 2022-04-12 8288 !ar->ab->hw_params.bios_sar_capa) {
> 5ad5b356e75f40 Baochen Qiang 2022-04-12 8289 ret = -EOPNOTSUPP;
> 5ad5b356e75f40 Baochen Qiang 2022-04-12 8290 goto exit;
> 5ad5b356e75f40 Baochen Qiang 2022-04-12 8291 }
> 5ad5b356e75f40 Baochen Qiang 2022-04-12 8292
> 5ad5b356e75f40 Baochen Qiang 2022-04-12 @8293 if (!sar || sar->type != NL80211_SAR_TYPE_POWER ||
> ^^^
> Checked too late

Baochen, please submit a fix for this.

2022-04-27 12:19:24

by Baochen Qiang

[permalink] [raw]
Subject: Re: [ammarfaizi2-block:kvalo/ath/pending 36/40] drivers/net/wireless/ath/ath11k/mac.c:8293 ath11k_mac_op_set_bios_sar_specs() warn: variable dereferenced before check 'sar' (see line 8280)


On 4/27/2022 7:19 PM, Kalle Valo wrote:
> + ath11k list
>
> Dan Carpenter <[email protected]> writes:
>
>> tree: https://github.com/ammarfaizi2/linux-block kvalo/ath/pending
>> head: c9a8efc35304a89fc0751649945909caf03eeb29
>> commit: 5ad5b356e75f402fec930cf0d77b6c7862850b55 [36/40] ath11k: Add support for SAR
>> config: x86_64-randconfig-m001-20220418 (https://download.01.org/0day-ci/archive/20220418/[email protected]/config)
>> compiler: gcc-11 (Debian 11.2.0-19) 11.2.0
>>
>> If you fix the issue, kindly add following tag as appropriate
>> Reported-by: kernel test robot <[email protected]>
>> Reported-by: Dan Carpenter <[email protected]>
>>
>> New smatch warnings:
>> drivers/net/wireless/ath/ath11k/mac.c:8293 ath11k_mac_op_set_bios_sar_specs() warn: variable dereferenced before check 'sar' (see line 8280)
>>
>> vim +/sar +8293 drivers/net/wireless/ath/ath11k/mac.c
>>
>> 5ad5b356e75f40 Baochen Qiang 2022-04-12 8276 static int ath11k_mac_op_set_bios_sar_specs(struct ieee80211_hw *hw,
>> 5ad5b356e75f40 Baochen Qiang 2022-04-12 8277 const struct cfg80211_sar_specs *sar)
>> 5ad5b356e75f40 Baochen Qiang 2022-04-12 8278 {
>> 5ad5b356e75f40 Baochen Qiang 2022-04-12 8279 struct ath11k *ar = hw->priv;
>> 5ad5b356e75f40 Baochen Qiang 2022-04-12 @8280 const struct cfg80211_sar_sub_specs *sspec = sar->sub_specs;
>> ^^^^^^^^^^^^^^
>> Dereference
>>
>> 5ad5b356e75f40 Baochen Qiang 2022-04-12 8281 int ret, index;
>> 5ad5b356e75f40 Baochen Qiang 2022-04-12 8282 u8 *sar_tbl;
>> 5ad5b356e75f40 Baochen Qiang 2022-04-12 8283 u32 i;
>> 5ad5b356e75f40 Baochen Qiang 2022-04-12 8284
>> 5ad5b356e75f40 Baochen Qiang 2022-04-12 8285 mutex_lock(&ar->conf_mutex);
>> 5ad5b356e75f40 Baochen Qiang 2022-04-12 8286
>> 5ad5b356e75f40 Baochen Qiang 2022-04-12 8287 if (!test_bit(WMI_TLV_SERVICE_BIOS_SAR_SUPPORT, ar->ab->wmi_ab.svc_map) ||
>> 5ad5b356e75f40 Baochen Qiang 2022-04-12 8288 !ar->ab->hw_params.bios_sar_capa) {
>> 5ad5b356e75f40 Baochen Qiang 2022-04-12 8289 ret = -EOPNOTSUPP;
>> 5ad5b356e75f40 Baochen Qiang 2022-04-12 8290 goto exit;
>> 5ad5b356e75f40 Baochen Qiang 2022-04-12 8291 }
>> 5ad5b356e75f40 Baochen Qiang 2022-04-12 8292
>> 5ad5b356e75f40 Baochen Qiang 2022-04-12 @8293 if (!sar || sar->type != NL80211_SAR_TYPE_POWER ||
>> ^^^
>> Checked too late
> Baochen, please submit a fix for this.

Sure, Kalle. I just sent the fix patch named "ath11k: Fix warning on
variable 'sar' dereference before check" to internal review.