public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Jan Beulich <jbeulich@suse.com>
To: "H.J. Lu" <hjl.tools@gmail.com>
Cc: Binutils <binutils@sourceware.org>
Subject: Re: [PATCH 1/7] x86: don't leak sub-architecture accumulated strings
Date: Fri, 1 Jul 2022 12:18:07 +0200	[thread overview]
Message-ID: <1041c98c-a2a4-af7d-5872-cded045f1a60@suse.com> (raw)
In-Reply-To: <CAMe9rOryv0ZLM_r8dgX=+zqAiwj7Xge8xn8bDLPRne6w01zrWQ@mail.gmail.com>

On 01.07.2022 00:54, H.J. Lu wrote:
> On Thu, Jun 30, 2022 at 5:53 AM Jan Beulich <jbeulich@suse.com> wrote:
>> --- a/gas/config/tc-i386.c
>> +++ b/gas/config/tc-i386.c
>> @@ -2871,6 +2871,7 @@ set_cpu_arch (int dummy ATTRIBUTE_UNUSED
>>                   check_cpu_arch_compatible (string, cpu_arch[j].flags);
>>
>>                   cpu_arch_name = cpu_arch[j].name;
>> +                 xfree (cpu_sub_arch_name);
>>                   cpu_sub_arch_name = NULL;
>>                   cpu_arch_flags = cpu_arch[j].flags;
>>                   if (flag_code == CODE_64BIT)
>> @@ -13406,6 +13407,7 @@ md_parse_option (int c, const char *arg)
>>                     continue;
>>
>>                   cpu_arch_name = cpu_arch[j].name;
>> +                 xfree (cpu_sub_arch_name);
>>                   cpu_sub_arch_name = NULL;
>>                   cpu_arch_flags = cpu_arch[j].flags;
>>                   cpu_arch_isa = cpu_arch[j].type;
>> @@ -14086,6 +14088,7 @@ i386_target_format (void)
>>         {
>>           static const i386_cpu_flags iamcu_flags = CPU_IAMCU_FLAGS;
>>           cpu_arch_name = "iamcu";
>> +         xfree (cpu_sub_arch_name);
>>           cpu_sub_arch_name = NULL;
>>           cpu_arch_flags = iamcu_flags;
>>           cpu_arch_isa = PROCESSOR_IAMCU;
>>
> 
> Can we just use free?

In principle yes, but I view using free() as inconsistent when the
allocation used xmalloc() or alike. These should pair, even if right
now xfree() simply aliases to free() - this could change down the
road, and then cause unnecessary code churn just to update all such
instances.

Jan

  reply	other threads:[~2022-07-01 10:18 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-30 12:52 [PATCH] gas/x86: .arch / -march= enhancements Jan Beulich
2022-06-30 12:53 ` [PATCH 1/7] x86: don't leak sub-architecture accumulated strings Jan Beulich
2022-06-30 22:54   ` H.J. Lu
2022-07-01 10:18     ` Jan Beulich [this message]
2022-07-01 19:44       ` H.J. Lu
2022-06-30 12:53 ` [PATCH 2/7] x86: de-duplicate sub-architecture strings accumulation Jan Beulich
2022-06-30 22:55   ` H.J. Lu
2022-06-30 12:53 ` [PATCH 3/7] x86: permit "default" with .arch Jan Beulich
2022-06-30 22:58   ` H.J. Lu
2022-06-30 12:54 ` [PATCH 4/7] x86: macro-ize cpu_arch[] entries Jan Beulich
2022-06-30 23:00   ` H.J. Lu
2022-06-30 12:54 ` [PATCH 5/7] x86: introduce fake processor type to mark sub-arch entries in cpu_arch[] Jan Beulich
2022-06-30 23:03   ` H.J. Lu
2022-06-30 12:55 ` [PATCH 6/7] x86: generalize disabling of sub-architectures Jan Beulich
2022-06-30 23:11   ` H.J. Lu
2022-06-30 12:55 ` [PATCH 7/7] x86: introduce a state stack for .arch Jan Beulich
2022-06-30 23:15   ` H.J. Lu

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=1041c98c-a2a4-af7d-5872-cded045f1a60@suse.com \
    --to=jbeulich@suse.com \
    --cc=binutils@sourceware.org \
    --cc=hjl.tools@gmail.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).