Re: [PATCH] pNFS: fix uninitialized pointer access

From: Sergey Bashirov
Date: Thu Jul 17 2025 - 04:53:31 EST


Hi Antonio, Dan,

I have an idea how to refactor the code a little to make the static
analyzer happy. Will send a patch soon, but first I want to check
that it won't affect functionality.

On Thu, Jul 17, 2025 at 10:01:42AM +0200, Antonio Quartulli wrote:
> On 17/07/2025 06:56, Dan Carpenter wrote:
> > No, it won't. I feel like the code is confusing enough that maybe a
> > comment is warranted. /* We always iterate through the loop at least
> > once so be_prev is correct. */
> >
>
> I agree a comment would help.

I see, will add a comment.

> > Another option would be to initialize the be_prev to NULL. This will
> > silence the uninitialized variable warning.
>
> But will likely trigger a potential NULL-ptr-deref, because the static
> analyzer believes we can get there with count==0.

I agree, this will most likely result in another warning.

--
Sergey Bashirov