mirror of
https://github.com/raspberrypi/linux.git
synced 2025-12-06 10:00:17 +00:00
iavf: fix dereference of null rx_buffer pointer
[ Upstream commit9fe06a5128] A recent commitefa14c3985("iavf: allow null RX descriptors") added a null pointer sanity check on rx_buffer, however, rx_buffer is being dereferenced before that check, which implies a null pointer dereference bug can potentially occur. Fix this by only dereferencing rx_buffer until after the null pointer check. Addresses-Coverity: ("Dereference before null check") Signed-off-by: Colin Ian King <colin.king@canonical.com> Tested-by: Andrew Bowers <andrewx.bowers@intel.com> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
5be48072f2
commit
c05dbbddde
@@ -1296,7 +1296,7 @@ static struct sk_buff *iavf_construct_skb(struct iavf_ring *rx_ring,
|
|||||||
struct iavf_rx_buffer *rx_buffer,
|
struct iavf_rx_buffer *rx_buffer,
|
||||||
unsigned int size)
|
unsigned int size)
|
||||||
{
|
{
|
||||||
void *va = page_address(rx_buffer->page) + rx_buffer->page_offset;
|
void *va;
|
||||||
#if (PAGE_SIZE < 8192)
|
#if (PAGE_SIZE < 8192)
|
||||||
unsigned int truesize = iavf_rx_pg_size(rx_ring) / 2;
|
unsigned int truesize = iavf_rx_pg_size(rx_ring) / 2;
|
||||||
#else
|
#else
|
||||||
@@ -1308,6 +1308,7 @@ static struct sk_buff *iavf_construct_skb(struct iavf_ring *rx_ring,
|
|||||||
if (!rx_buffer)
|
if (!rx_buffer)
|
||||||
return NULL;
|
return NULL;
|
||||||
/* prefetch first cache line of first page */
|
/* prefetch first cache line of first page */
|
||||||
|
va = page_address(rx_buffer->page) + rx_buffer->page_offset;
|
||||||
prefetch(va);
|
prefetch(va);
|
||||||
#if L1_CACHE_BYTES < 128
|
#if L1_CACHE_BYTES < 128
|
||||||
prefetch(va + L1_CACHE_BYTES);
|
prefetch(va + L1_CACHE_BYTES);
|
||||||
@@ -1362,7 +1363,7 @@ static struct sk_buff *iavf_build_skb(struct iavf_ring *rx_ring,
|
|||||||
struct iavf_rx_buffer *rx_buffer,
|
struct iavf_rx_buffer *rx_buffer,
|
||||||
unsigned int size)
|
unsigned int size)
|
||||||
{
|
{
|
||||||
void *va = page_address(rx_buffer->page) + rx_buffer->page_offset;
|
void *va;
|
||||||
#if (PAGE_SIZE < 8192)
|
#if (PAGE_SIZE < 8192)
|
||||||
unsigned int truesize = iavf_rx_pg_size(rx_ring) / 2;
|
unsigned int truesize = iavf_rx_pg_size(rx_ring) / 2;
|
||||||
#else
|
#else
|
||||||
@@ -1374,6 +1375,7 @@ static struct sk_buff *iavf_build_skb(struct iavf_ring *rx_ring,
|
|||||||
if (!rx_buffer)
|
if (!rx_buffer)
|
||||||
return NULL;
|
return NULL;
|
||||||
/* prefetch first cache line of first page */
|
/* prefetch first cache line of first page */
|
||||||
|
va = page_address(rx_buffer->page) + rx_buffer->page_offset;
|
||||||
prefetch(va);
|
prefetch(va);
|
||||||
#if L1_CACHE_BYTES < 128
|
#if L1_CACHE_BYTES < 128
|
||||||
prefetch(va + L1_CACHE_BYTES);
|
prefetch(va + L1_CACHE_BYTES);
|
||||||
|
|||||||
Reference in New Issue
Block a user