
+static int validate_params(struct bpf_prog *xdp_prog, void *fwd)
+{
+	if (!xdp_prog || !fwd)
+		return -EINVAL;
+	return 0;
+}

static int xdp_do_generic_redirect_map(struct net_device *dev,
				       struct sk_buff *skb,
				       struct xdp_buff *xdp,
				       struct bpf_prog *xdp_prog,
				       void *fwd,
				       enum bpf_map_type map_type, u32 map_id)
{
+	int err = validate_params(xdp_prog, fwd);
+	if (err)
+		return err;

	struct bpf_redirect_info *ri = this_cpu_ptr(&bpf_redirect_info);
	// ... rest of the function
