]> git.baikalelectronics.ru Git - kernel.git/commit
xsk: Do not write NULL in SW ring at allocation failure
authorMagnus Karlsson <magnus.karlsson@intel.com>
Mon, 28 Mar 2022 14:21:20 +0000 (16:21 +0200)
committerAlexei Starovoitov <ast@kernel.org>
Tue, 29 Mar 2022 02:56:28 +0000 (19:56 -0700)
commit67c5dcc5c6e031482de79c68a97736cad886407e
tree4b4d622f23f26e50fffadefb1382f9230ed108ad
parent4a4afac34c7df3f713df4c805d181384e4c21ce5
xsk: Do not write NULL in SW ring at allocation failure

For the case when xp_alloc_batch() is used but the batched allocation
cannot be used, there is a slow path that uses the non-batched
xp_alloc(). When it fails to allocate an entry, it returns NULL. The
current code wrote this NULL into the entry of the provided results
array (pointer to the driver SW ring usually) and returned. This might
not be what the driver expects and to make things simpler, just write
successfully allocated xdp_buffs into the SW ring,. The driver might
have information in there that is still important after an allocation
failure.

Note that at this point in time, there are no drivers using
xp_alloc_batch() that could trigger this slow path. But one might get
added.

Fixes: dd57bd1b0d31 ("xsk: Batched buffer allocation for the pool")
Signed-off-by: Magnus Karlsson <magnus.karlsson@intel.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20220328142123.170157-2-maciej.fijalkowski@intel.com
net/xdp/xsk_buff_pool.c