]> git.itanic.dy.fi Git - linux-stable/commitdiff
wifi: iwlegacy: 4965: corrected fix for potential off-by-one overflow in il4965_rs_fi...
authorStanislaw Gruszka <stf_xl@wp.pl>
Mon, 15 Aug 2022 07:37:37 +0000 (09:37 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 15 Sep 2022 10:17:02 +0000 (12:17 +0200)
commit 6d0ef7241553f3553a0a2764c69b07892705924c upstream.

This reverts commit a8eb8e6f7159c7c20c0ddac428bde3d110890aa7 as
it can cause invalid link quality command sent to the firmware
and address the off-by-one issue by fixing condition of while loop.

Cc: stable@vger.kernel.org
Fixes: a8eb8e6f7159 ("wifi: iwlegacy: 4965: fix potential off-by-one overflow in il4965_rs_fill_link_cmd()")
Signed-off-by: Stanislaw Gruszka <stf_xl@wp.pl>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220815073737.GA999388@wp.pl
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/wireless/intel/iwlegacy/4965-rs.c

index f204e139e5f020226203655a672b120da57ac047..cfa54d35ba2e0febcba5588904f0ee656e5e637a 100644 (file)
@@ -2422,7 +2422,7 @@ il4965_rs_fill_link_cmd(struct il_priv *il, struct il_lq_sta *lq_sta,
                /* Repeat initial/next rate.
                 * For legacy IL_NUMBER_TRY == 1, this loop will not execute.
                 * For HT IL_HT_NUMBER_TRY == 3, this executes twice. */
-               while (repeat_rate > 0) {
+               while (repeat_rate > 0 && idx < (LINK_QUAL_MAX_RETRY_NUM - 1)) {
                        if (is_legacy(tbl_type.lq_type)) {
                                if (ant_toggle_cnt < NUM_TRY_BEFORE_ANT_TOGGLE)
                                        ant_toggle_cnt++;
@@ -2441,8 +2441,6 @@ il4965_rs_fill_link_cmd(struct il_priv *il, struct il_lq_sta *lq_sta,
                            cpu_to_le32(new_rate);
                        repeat_rate--;
                        idx++;
-                       if (idx >= LINK_QUAL_MAX_RETRY_NUM)
-                               goto out;
                }
 
                il4965_rs_get_tbl_info_from_mcs(new_rate, lq_sta->band,
@@ -2487,7 +2485,6 @@ il4965_rs_fill_link_cmd(struct il_priv *il, struct il_lq_sta *lq_sta,
                repeat_rate--;
        }
 
-out:
        lq_cmd->agg_params.agg_frame_cnt_limit = LINK_QUAL_AGG_FRAME_LIMIT_DEF;
        lq_cmd->agg_params.agg_dis_start_th = LINK_QUAL_AGG_DISABLE_START_DEF;