Re: [PATCH] fix: Skip if symbol have no op when handle_qualifiers

Chris Li <[email protected]>
Newsgroups org.kernel.vger.linux-sparse
Message-ID <CACePvbVcTrP06zPu6j7P7ui4UySYdGn+vqnyDLfdN4LfyRfbYA@mail.gmail.com>
Applied in sparse-dev.

Thanks

Chris

On Mon, Sep 23, 2024 at 1:41 AM wenlunpeng <[email protected]> wrote:
>
> Missing s->op will cause a SIGSEGV when trying to get s->op->type.
>
> I encountered the issue when building with sparse in a linux kernel tree
> containing a vendor network driver. A simple `make` will success but a
> `make C=2` will exit with exit-code 139. The coredump shows that s->op
> here is NULL when dealing with a source code line like:
>         u8 *byte;
>
> Lines like this exist everywhere. I cannot figure out why just this file
> breaks sparse. But I think the NULL judge is needed here.
>
> Signed-off-by: wenlunpeng <[email protected]>
> ---
>  parse.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/parse.c b/parse.c
> index 3d6fef7c..66d0be04 100644
> --- a/parse.c
> +++ b/parse.c
> @@ -1505,7 +1505,7 @@ static struct token *handle_qualifiers(struct token *t, struct decl_state *ctx)
>  {
>         while (token_type(t) == TOKEN_IDENT) {
>                 struct symbol *s = lookup_keyword(t->ident, NS_TYPEDEF);
> -               if (!s)
> +               if (!s || !s->op)
>                         break;
>                 if (!(s->op->type & (KW_ATTRIBUTE | KW_QUALIFIER)))
>                         break;
> --
> 2.20.1
>
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.