Re: [PATCH Part1 RFC v4 15/36] x86/mm: Add support to validate memory when changing C-bit

Borislav Petkov
2021-08-17T18:17:09Z

On Tue, Aug 17, 2021 at 01:07:40PM -0500, Brijesh Singh wrote:
> > > + if (!desc)
> > > + panic("failed to allocate memory");
> >
> > Make that error message more distinctive so that *if* it happens, one
> > can pinpoint the place in the code where the panic comes from.
> >
>
> Now I am running checkpatch and notice that it complain about the message
> too. I can add a BUG() or WARN() to get the stack trace before the crashing.

checkpatch complains because there's a kmalloc before it and if it
fails, the mm core will issue a warning so there's no need for a warning
here.

But in this case, you want to panic and checkpatch doesn't see that so
you can ignore it here and leave the panic message but make it more
distinctive so one can find it by grepping. IOW, something like

if (!desc)
panic("SEV-SNP: Failed to allocame memory for PSC descriptor");

Thx.

--
Regards/Gruss,
Boris.