Skip to content

Commit aaa3c08

Browse files
michichdavem330
authored andcommitted
qede: avoid uninitialized entries in coal_entry array
Even after commit 908d4bb ("qede: fix interrupt coalescing configuration"), some entries of the coal_entry array may theoretically be used uninitialized: 1. qede_alloc_fp_array() allocates QEDE_MAX_RSS_CNT entries for coal_entry. The initial allocation uses kcalloc, so everything is initialized. 2. The user sets a small number of queues (ethtool -L). coal_entry is reallocated for the actual small number of queues. 3. The user sets a bigger number of queues. coal_entry is reallocated bigger. The added entries are not necessarily initialized. In practice, the reallocations will actually keep using the originally allocated region of memory, but we should not rely on it. The reallocation is unnecessary. coal_entry can always have QEDE_MAX_RSS_CNT entries. Fixes: 908d4bb ("qede: fix interrupt coalescing configuration") Signed-off-by: Michal Schmidt <[email protected]> Nacked-by: Manish Chopra <[email protected]> Acked-by: Manish Chopra <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 5064561 commit aaa3c08

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

drivers/net/ethernet/qlogic/qede/qede_main.c

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -963,7 +963,6 @@ static int qede_alloc_fp_array(struct qede_dev *edev)
963963
{
964964
u8 fp_combined, fp_rx = edev->fp_num_rx;
965965
struct qede_fastpath *fp;
966-
void *mem;
967966
int i;
968967

969968
edev->fp_array = kcalloc(QEDE_QUEUE_CNT(edev),
@@ -974,20 +973,14 @@ static int qede_alloc_fp_array(struct qede_dev *edev)
974973
}
975974

976975
if (!edev->coal_entry) {
977-
mem = kcalloc(QEDE_MAX_RSS_CNT(edev),
978-
sizeof(*edev->coal_entry), GFP_KERNEL);
979-
} else {
980-
mem = krealloc(edev->coal_entry,
981-
QEDE_QUEUE_CNT(edev) * sizeof(*edev->coal_entry),
982-
GFP_KERNEL);
983-
}
984-
985-
if (!mem) {
986-
DP_ERR(edev, "coalesce entry allocation failed\n");
987-
kfree(edev->coal_entry);
988-
goto err;
976+
edev->coal_entry = kcalloc(QEDE_MAX_RSS_CNT(edev),
977+
sizeof(*edev->coal_entry),
978+
GFP_KERNEL);
979+
if (!edev->coal_entry) {
980+
DP_ERR(edev, "coalesce entry allocation failed\n");
981+
goto err;
982+
}
989983
}
990-
edev->coal_entry = mem;
991984

992985
fp_combined = QEDE_QUEUE_CNT(edev) - fp_rx - edev->fp_num_tx;
993986

0 commit comments

Comments
 (0)