Skip to content

Commit aec806f

Browse files
pkitszelanguy11
authored andcommitted
ixgbe: avoid sleeping allocation in ixgbe_ipsec_vf_add_sa()
Change kzalloc() flags used in ixgbe_ipsec_vf_add_sa() to GFP_ATOMIC, to avoid sleeping in IRQ context. Dan Carpenter, with the help of Smatch, has found following issue: The patch eda0333: "ixgbe: add VF IPsec management" from Aug 13, 2018 (linux-next), leads to the following Smatch static checker warning: drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.c:917 ixgbe_ipsec_vf_add_sa() warn: sleeping in IRQ context The call tree that Smatch is worried about is: ixgbe_msix_other() <- IRQ handler -> ixgbe_msg_task() -> ixgbe_rcv_msg_from_vf() -> ixgbe_ipsec_vf_add_sa() Fixes: eda0333 ("ixgbe: add VF IPsec management") Reported-by: Dan Carpenter <[email protected]> Link: https://lore.kernel.org/intel-wired-lan/[email protected] Reviewed-by: Michal Kubiak <[email protected]> Signed-off-by: Przemek Kitszel <[email protected]> Reviewed-by: Shannon Nelson <[email protected]> Tested-by: Pucha Himasekhar Reddy <[email protected]> (A Contingent worker at Intel) Signed-off-by: Tony Nguyen <[email protected]>
1 parent 1cb7fdb commit aec806f

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -914,7 +914,13 @@ int ixgbe_ipsec_vf_add_sa(struct ixgbe_adapter *adapter, u32 *msgbuf, u32 vf)
914914
goto err_out;
915915
}
916916

917-
xs = kzalloc(sizeof(*xs), GFP_KERNEL);
917+
algo = xfrm_aead_get_byname(aes_gcm_name, IXGBE_IPSEC_AUTH_BITS, 1);
918+
if (unlikely(!algo)) {
919+
err = -ENOENT;
920+
goto err_out;
921+
}
922+
923+
xs = kzalloc(sizeof(*xs), GFP_ATOMIC);
918924
if (unlikely(!xs)) {
919925
err = -ENOMEM;
920926
goto err_out;
@@ -930,14 +936,8 @@ int ixgbe_ipsec_vf_add_sa(struct ixgbe_adapter *adapter, u32 *msgbuf, u32 vf)
930936
memcpy(&xs->id.daddr.a4, sam->addr, sizeof(xs->id.daddr.a4));
931937
xs->xso.dev = adapter->netdev;
932938

933-
algo = xfrm_aead_get_byname(aes_gcm_name, IXGBE_IPSEC_AUTH_BITS, 1);
934-
if (unlikely(!algo)) {
935-
err = -ENOENT;
936-
goto err_xs;
937-
}
938-
939939
aead_len = sizeof(*xs->aead) + IXGBE_IPSEC_KEY_BITS / 8;
940-
xs->aead = kzalloc(aead_len, GFP_KERNEL);
940+
xs->aead = kzalloc(aead_len, GFP_ATOMIC);
941941
if (unlikely(!xs->aead)) {
942942
err = -ENOMEM;
943943
goto err_xs;

0 commit comments

Comments
 (0)