Subject: Re: [net-next 02/14] lib: cpu_rmap: Use allocator for rmap entries

From: Jakub Kicinski <[email-masked]>
Date: Tue, 21 Mar 2023 20:40:28 -0700

On Mon, 20 Mar 2023 10:51:32 -0700 Saeed Mahameed wrote:
> +static int get_free_index(struct cpu_rmap *rmap)
> +{
> +	int i;
> +
> +	for (i = 0; i < rmap->size; i++)
> +		if (!rmap->obj[i])
> +			return i;
> +
> +	return -1;

-ENOSPC, why invent a special value ..

> @@ -295,7 +307,11 @@ int irq_cpu_rmap_add(struct cpu_rmap *rmap, int irq)
>  	glue->notify.release = irq_cpu_rmap_release;
>  	glue->rmap = rmap;
>  	cpu_rmap_get(rmap);
> -	glue->index = cpu_rmap_add(rmap, glue);
> +	rc = cpu_rmap_add(rmap, glue);
> +	if (rc == -1)
> +		return -ENOSPC;

which you then have to convert into an errno ?

Also you leak glue here.