msm: ipa2: Add check to validate rule_cnt

Add proper check to validate table rule count
which may lead to overflow error.

Change-Id: Idfa86878db49ad4803f8902c995eb4186a2d3523
Signed-off-by: Praveen Kurapati <pkurapat@codeaurora.org>
This commit is contained in:
Praveen Kurapati
2020-12-07 18:39:16 +05:30
committed by Michael Bestas
parent 6e3dea8b7b
commit f259b6f663
3 changed files with 9 additions and 2 deletions

View File

@@ -1055,7 +1055,10 @@ static int __ipa_add_flt_rule(struct ipa_flt_tbl *tbl, enum ipa_ip_type ip,
} else {
list_add(&entry->link, &tbl->head_flt_rule_list);
}
tbl->rule_cnt++;
if (tbl->rule_cnt < IPA_RULE_CNT_MAX)
tbl->rule_cnt++;
else
return -EINVAL;
if (entry->rt_tbl)
entry->rt_tbl->ref_cnt++;
id = ipa_id_alloc(entry);

View File

@@ -204,6 +204,7 @@
#define IPA2_ACTIVE_CLIENTS_LOG_LINE_LEN 96
#define IPA2_ACTIVE_CLIENTS_LOG_HASHTABLE_SIZE 50
#define IPA2_ACTIVE_CLIENTS_LOG_NAME_LEN 40
#define IPA_RULE_CNT_MAX 512
struct ipa2_active_client_htable_entry {
struct hlist_node list;

View File

@@ -1077,7 +1077,10 @@ static int __ipa_add_rt_rule(enum ipa_ip_type ip, const char *name,
list_add_tail(&entry->link, &tbl->head_rt_rule_list);
else
list_add(&entry->link, &tbl->head_rt_rule_list);
tbl->rule_cnt++;
if (tbl->rule_cnt < IPA_RULE_CNT_MAX)
tbl->rule_cnt++;
else
return -EINVAL;
if (entry->hdr)
entry->hdr->ref_cnt++;
else if (entry->proc_ctx)