Re: [PATCH V2] proc: Fix the issue of proc_mem_open returning NULL

From: Andrew Morton
Date: Thu Mar 27 2025 - 15:24:56 EST


On Mon, 24 Mar 2025 21:14:48 -0700 Penglei Jiang <superman.xpt@xxxxxxxxx> wrote:

> > > if (IS_ERR(mm))
> > > -return mm == ERR_PTR(-ESRCH) ? NULL : mm;
> > > +return mm;
> > >
> > > /* ensure this mm_struct can't be freed */
> > > mmgrab(mm);
> > > --
> > > 2.17.1
> > >
>
> Mateusz Guzik provides valuable suggestions.
>
> Complete the missing NULL checks.

proc_mem_open() can return errno, NULL or mm_struct*. It isn't obvious
why.

While you're in there can you please add documentation to
proc_mem_open() which explains its return values?