提交 aaa3c08e 编写于 作者: M Michal Schmidt 提交者: David S. Miller

qede: avoid uninitialized entries in coal_entry array

Even after commit 908d4bb7 ("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: 908d4bb7 ("qede: fix interrupt coalescing configuration")
Signed-off-by: NMichal Schmidt <mschmidt@redhat.com>
Nacked-by: NManish Chopra <manishc@marvell.com>
Acked-by: NManish Chopra <manishc@marvell.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 50645610
......@@ -963,7 +963,6 @@ static int qede_alloc_fp_array(struct qede_dev *edev)
{
u8 fp_combined, fp_rx = edev->fp_num_rx;
struct qede_fastpath *fp;
void *mem;
int i;
edev->fp_array = kcalloc(QEDE_QUEUE_CNT(edev),
......@@ -974,20 +973,14 @@ static int qede_alloc_fp_array(struct qede_dev *edev)
}
if (!edev->coal_entry) {
mem = kcalloc(QEDE_MAX_RSS_CNT(edev),
sizeof(*edev->coal_entry), GFP_KERNEL);
} else {
mem = krealloc(edev->coal_entry,
QEDE_QUEUE_CNT(edev) * sizeof(*edev->coal_entry),
edev->coal_entry = kcalloc(QEDE_MAX_RSS_CNT(edev),
sizeof(*edev->coal_entry),
GFP_KERNEL);
}
if (!mem) {
if (!edev->coal_entry) {
DP_ERR(edev, "coalesce entry allocation failed\n");
kfree(edev->coal_entry);
goto err;
}
edev->coal_entry = mem;
}
fp_combined = QEDE_QUEUE_CNT(edev) - fp_rx - edev->fp_num_tx;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册