mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-30 07:34:12 +08:00
net: mana: Check if netdev/napi_alloc_frag returns single page
netdev/napi_alloc_frag() may fall back to single page which is smaller than the requested size. Add error checking to avoid memory overwritten. Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
5c74064f43
commit
df18f2da30
@ -553,6 +553,14 @@ static int mana_pre_alloc_rxbufs(struct mana_port_context *mpc, int new_mtu)
|
|||||||
va = netdev_alloc_frag(mpc->rxbpre_alloc_size);
|
va = netdev_alloc_frag(mpc->rxbpre_alloc_size);
|
||||||
if (!va)
|
if (!va)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
|
page = virt_to_head_page(va);
|
||||||
|
/* Check if the frag falls back to single page */
|
||||||
|
if (compound_order(page) <
|
||||||
|
get_order(mpc->rxbpre_alloc_size)) {
|
||||||
|
put_page(page);
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
page = dev_alloc_page();
|
page = dev_alloc_page();
|
||||||
if (!page)
|
if (!page)
|
||||||
@ -1504,6 +1512,13 @@ static void *mana_get_rxfrag(struct mana_rxq *rxq, struct device *dev,
|
|||||||
|
|
||||||
if (!va)
|
if (!va)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
page = virt_to_head_page(va);
|
||||||
|
/* Check if the frag falls back to single page */
|
||||||
|
if (compound_order(page) < get_order(rxq->alloc_size)) {
|
||||||
|
put_page(page);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
page = dev_alloc_page();
|
page = dev_alloc_page();
|
||||||
if (!page)
|
if (!page)
|
||||||
|
Loading…
Reference in New Issue
Block a user