From: Johannes Berg Date: Mon, 18 Jun 2018 07:53:36 +0000 (+0200) Subject: iwlwifi: pcie gen2: check iwl_pcie_gen2_set_tb() return value X-Git-Url: http://git.cdn.openwrt.org/?a=commitdiff_plain;h=76dd61d2c57e881020cd2ea61994bf2dc8aefd84;p=openwrt%2Fstaging%2Fblogic.git iwlwifi: pcie gen2: check iwl_pcie_gen2_set_tb() return value If we use the iwl_pcie_gen2_set_tb() return value for BIT(), we should validate that it's not going to be negative, so do the check and bail out if we hit an error. We shouldn't, as we check if it'll fit beforehand, but better be safe. Fixes: ab6c644539e9 ("iwlwifi: pcie: copy TX functions to new transport") Signed-off-by: Johannes Berg Signed-off-by: Luca Coelho --- diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/tx-gen2.c b/drivers/net/wireless/intel/iwlwifi/pcie/tx-gen2.c index ba9d37bed4c2..b71cf55480fc 100644 --- a/drivers/net/wireless/intel/iwlwifi/pcie/tx-gen2.c +++ b/drivers/net/wireless/intel/iwlwifi/pcie/tx-gen2.c @@ -438,6 +438,8 @@ static int iwl_pcie_gen2_tx_add_frags(struct iwl_trans *trans, return -ENOMEM; tb_idx = iwl_pcie_gen2_set_tb(trans, tfd, tb_phys, skb_frag_size(frag)); + if (tb_idx < 0) + return tb_idx; out_meta->tbs |= BIT(tb_idx); }