On Tue, 2022-08-23 at 01:21 -0600, Vishal Verma wrote:
> A NULL check in region_action() implies that 'decoder' might be NULL, but
> later we dereference it during cxl_decoder_foreach().
> 
> Since cxl_decoder_foreach() won't ever enter the loop with a NULL decoder,
> the check was superfluous. Remove it.
> 
> Cc: Dan Williams <[email protected]>
> Signed-off-by: Vishal Verma <[email protected]>
> ---
>  cxl/region.c | 2 --
>  1 file changed, 2 deletions(-)
> 
> diff --git a/cxl/region.c b/cxl/region.c
> index a30313c..9372d6b 100644
> --- a/cxl/region.c
> +++ b/cxl/region.c
> @@ -688,8 +688,6 @@ static int region_action(int argc, const char **argv, 
> struct cxl_ctx *ctx,
>                 cxl_decoder_foreach (port, decoder) {
>                         decoder = util_cxl_decoder_filter(decoder,
>                                                           param.root_decoder);
> -                       if (!decoder)
> -                               continue;

Hm, this is actually wrong. We need to save the filter results in a new
variable, and NULL check that, while keeping the original 'decoder'
variable intact for the loop. I'll send v2.

>                         rc = decoder_region_action(p, decoder, action, count);
>                         if (rc)
>                                 err_rc = rc;

Reply via email to