On 1/21/25 17:06, Eugen Hristev wrote:
> psz_init_zones is not supposed to return NULL. It returns an errno,
> and its caller always checks for an errno to look for a problem.
> If the caller receives a NULL as a return, this code will go further
> without any errors:
> 
>         cxt->kpszs = psz_init_zones(PSTORE_TYPE_DMESG, &off,
>                         info->total_size - off_size,
>                         info->kmsg_size, &cxt->kmsg_max_cnt);
>         if (IS_ERR(cxt->kpszs)) {
>                 err = PTR_ERR(cxt->kpszs);
>                 cxt->kpszs = NULL;
>                 goto free_out;
>         }
> 
> Later, when dereferencing kpszs, a panic would occur.
> 
> Thus, to avoid this possible crash, it's better to avoid returning NULL
> in psz_init_zones, and just return -EINVAL if the parameters received
> are wrong (in this case, a zero size request).

Please disregard this patch. I found a case when NULL is being used
meaningfully so I have to find a better way to handle this.

Sorry for the noise.


Reply via email to