lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 18 Jan 2021 17:32:18 +0200
From:   Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To:     "Rafael J. Wysocki" <rafael@...nel.org>
Cc:     Hans de Goede <hdegoede@...hat.com>,
        "Rafael J. Wysocki" <rjw@...ysocki.net>,
        Linux ACPI <linux-acpi@...r.kernel.org>,
        LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v1 1/2] ACPI: scan: Rearrange memory allocation in
 acpi_device_add()

On Mon, Jan 18, 2021 at 04:16:16PM +0100, Rafael J. Wysocki wrote:
> On Sat, Jan 16, 2021 at 1:37 PM Hans de Goede <hdegoede@...hat.com> wrote:
> > On 1/14/21 7:46 PM, Rafael J. Wysocki wrote:

...

> > When I have cases like this, where 2 mallocs are necessary I typically do it like this:
> >
> >         const char *bus_id;
> >
> >         ...
> >
> >         } else {
> >                 acpi_device_bus_id = kzalloc(sizeof(*acpi_device_bus_id),
> >                                              GFP_KERNEL);
> >                 bus_id = kstrdup_const(acpi_device_hid(device), GFP_KERNEL);
> >                 if (!acpi_device_bus_id || !bus_id) {
> >                         kfree(acpi_device_bus_id);


> >                         kfree(bus_id);

Just to be sure, shouldn't it be kfree_const() ?

> >                         result = -ENOMEM;
> >                         goto err_unlock;
> >                 }
> >                 acpi_device_bus_id->bus_id = bus_id;
> >                 list_add_tail(&acpi_device_bus_id->node, &acpi_bus_id_list);
> >         }
> >
> >         ...
> >
> > So that there is only one if / 1 error-handling path for both mallocs.
> > I personally find this a bit cleaner.

-- 
With Best Regards,
Andy Shevchenko


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ