Re: [PATCH] nfp: bpf: Add check for nfp_app_ctrl_msg_alloc()

From: Guruswamy Basavaiah
Date: Mon Feb 17 2025 - 16:08:52 EST


Hi Haoxiang,
Nitpick: The brackets `{}` in the `if (!skb)` check are not required
for a single-statement block. As per the Linux kernel coding style,
it's preferable to omit them unless necessary for readability.
Guru

On Mon, Feb 17, 2025 at 7:53 PM Haoxiang Li <haoxiang_li2024@xxxxxxx> wrote:
>
> Add check for the return value of nfp_app_ctrl_msg_alloc() in
> nfp_bpf_cmsg_alloc() to prevent null pointer dereference.
>
> Fixes: ff3d43f7568c ("nfp: bpf: implement helpers for FW map ops")
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Haoxiang Li <haoxiang_li2024@xxxxxxx>
> ---
> drivers/net/ethernet/netronome/nfp/bpf/cmsg.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/net/ethernet/netronome/nfp/bpf/cmsg.c b/drivers/net/ethernet/netronome/nfp/bpf/cmsg.c
> index 2ec62c8d86e1..09ea1bc72097 100644
> --- a/drivers/net/ethernet/netronome/nfp/bpf/cmsg.c
> +++ b/drivers/net/ethernet/netronome/nfp/bpf/cmsg.c
> @@ -20,6 +20,9 @@ nfp_bpf_cmsg_alloc(struct nfp_app_bpf *bpf, unsigned int size)
> struct sk_buff *skb;
>
> skb = nfp_app_ctrl_msg_alloc(bpf->app, size, GFP_KERNEL);
> + if (!skb) {
> + return NULL;
> + }
> skb_put(skb, size);
>
> return skb;
> --
> 2.25.1
>
>

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature