public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Fangrui Song <i@maskray.me>
To: jacob navia <jacob@jacob.remcomp.fr>
Cc: Torbjorn SVENSSON <torbjorn.svensson@foss.st.com>,
	binutils@sourceware.org
Subject: Re: Missing NULL check
Date: Tue, 12 Sep 2023 12:34:35 -0700	[thread overview]
Message-ID: <DS7PR12MB5765A9A6780569A2E4A9AC67CBF1A@DS7PR12MB5765.namprd12.prod.outlook.com> (raw)
In-Reply-To: <fdf4313e-5b1b-0633-e0fa-d66eb9d25ba7@foss.st.com>

On Tue, Sep 12, 2023 at 11:50 AM Torbjorn SVENSSON via Binutils
<binutils@sourceware.org> wrote:
>
>
>
> On 2023-09-12 17:40, jacob navia wrote:
> > This is very similar to the last one:
> > FILE:  elf-attrs.c line 232
> > FUNCTION: elf_new_obj_attr
> > /* Allocate/find an object attribute.  */
> > static obj_attribute *
> > elf_new_obj_attr (bfd *abfd, int vendor, unsigned int tag)
> > {
> >    obj_attribute *attr;
> >    obj_attribute_list *list;
> >    obj_attribute_list *p;
> >    obj_attribute_list **lastp;
> >
> >
> >    if (tag < NUM_KNOWN_OBJ_ATTRIBUTES)
> >      {
> >        /* Known tags are preallocated.  */
> >        attr = &elf_known_obj_attributes (abfd)[vendor][tag];
> >      }
> >    else
> >      {
> >        /* Create a new tag.  */
> >        list = (obj_attribute_list *)
> >       bfd_alloc (abfd, sizeof (obj_attribute_list));
> >        memset (list, 0, sizeof (obj_attribute_list));
> >        list->tag = tag;
> >        /* Keep the tag list in order.  */
> >        lastp = &elf_other_obj_attributes (abfd)[vendor];
> >        for (p = *lastp; p; p = p->next)
> >       {
> >         if (tag < p->tag)
> >           break;
> >         lastp = &p->next;
> >       }
> >        list->next = *lastp;
> >        *lastp = list;
> >        attr = &list->attr;
> >      }
> >
> >    return attr;
> > }
> >
> > bfd_alloc can return NULL. This is not checked
> > How to fix:
> > Add
> > if (list == NULL) return NULL;
>
> I've seen that you've sent a few mails similar to this one now.
> First of all, thanks for trying to improve the quality on binutils!
>
> If you want to help binutils even more, I would suggest that you create
> a proper patch and submit that instead of a mail with the above content
> as it would make it less work for a maintainer to actually commit your fix.
>
> Note, the above is just my personal opinion and might not be align with
> the preferences of the binutils maintainers.
>
> Kind regards,
> Torbjörn

I share the same opinion as Torbjorn's.

You might consider configuring  `git send-email` with a MTA (e.g.
msmtp), then you can send [PATCH] messages that a maintainer can apply
with ease:

    b4 am 'https://inbox.sourceware.org/binutils/DB9PR08MB647413BBA3340351A802035F81F1A@DB9PR08MB6474.eurprd08.prod.outlook.com/T/#t'
-o - | git am

(See https://josefbacik.github.io/kernel/2021/10/18/lei-and-b4.html)

If a patch is straightforward enough and a maintainer notices it, I am
sure this will make it faster for a fix to be applied.

  reply	other threads:[~2023-09-12 19:43 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-12 15:40 jacob navia
2023-09-12 18:50 ` Torbjorn SVENSSON
2023-09-12 19:34   ` Fangrui Song [this message]
2023-09-13 10:57     ` Nick Clifton
     [not found]   ` <DS7PR12MB5765DD3A03E4B143B950C3D6CBF1A@DS7PR12MB5765.namprd12.prod.outlook.com>
2023-09-13 14:28     ` jacob navia
2023-09-13  6:50 ` Alan Modra

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=DS7PR12MB5765A9A6780569A2E4A9AC67CBF1A@DS7PR12MB5765.namprd12.prod.outlook.com \
    --to=i@maskray.me \
    --cc=binutils@sourceware.org \
    --cc=jacob@jacob.remcomp.fr \
    --cc=torbjorn.svensson@foss.st.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).