sfc: handle error pointers returned by rhashtable_lookup_get_insert_fast()
authorEdward Cree <ecree.xilinx@gmail.com>
Tue, 19 Sep 2023 18:39:49 +0000 (19:39 +0100)
committerPaolo Abeni <pabeni@redhat.com>
Thu, 21 Sep 2023 08:37:16 +0000 (10:37 +0200)
commitfc21f08375dbf654bd1fda748261955de580ac14
tree08ad1e1b2a82bc17d90cca5102ee6cc9828ddd64
parent1703b2e0de653b459ca6230be32ce7f2ea0ae7ee
sfc: handle error pointers returned by rhashtable_lookup_get_insert_fast()

Several places in TC offload code assumed that the return from
 rhashtable_lookup_get_insert_fast() was always either NULL or a valid
 pointer to an existing entry, but in fact that function can return an
 error pointer.  In that case, perform the usual cleanup of the newly
 created entry, then pass up the error, rather than attempting to take a
 reference on the old entry.

Fixes: d902e1a737d4 ("sfc: bare bones TC offload on EF100")
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Signed-off-by: Edward Cree <ecree.xilinx@gmail.com>
Link: https://lore.kernel.org/r/20230919183949.59392-1-edward.cree@amd.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
drivers/net/ethernet/sfc/tc.c
drivers/net/ethernet/sfc/tc_conntrack.c
drivers/net/ethernet/sfc/tc_counters.c
drivers/net/ethernet/sfc/tc_encap_actions.c