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] [day] [month] [year] [list]
Message-ID: <CAJZ5v0irjA9sXjA_arW8QWueJ-C3OJHX7yDwU6TT=EAM7hjq3A@mail.gmail.com>
Date: Tue, 12 Aug 2025 15:16:40 +0200
From: "Rafael J. Wysocki" <rafael@...nel.org>
To: Liao Yuanhong <liaoyuanhong@...o.com>
Cc: "Rafael J. Wysocki" <rafael@...nel.org>, Len Brown <lenb@...nel.org>, 
	Bjorn Helgaas <bhelgaas@...gle.com>, "open list:ACPI" <linux-acpi@...r.kernel.org>, 
	"open list:PCI SUBSYSTEM" <linux-pci@...r.kernel.org>, open list <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] PCI: acpiphp_ibm: Using kmemdup() to simplify code

On Mon, Aug 11, 2025 at 10:22 AM Liao Yuanhong <liaoyuanhong@...o.com> wrote:
>
> Use kmemdup() to replace the original code's allocate-and-copy operations.
> It enhances code readability and simplifies nested conditionals.
>
> Signed-off-by: Liao Yuanhong <liaoyuanhong@...o.com>
> ---
>  drivers/pci/hotplug/acpiphp_ibm.c | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/pci/hotplug/acpiphp_ibm.c b/drivers/pci/hotplug/acpiphp_ibm.c
> index 18e01cd55a8e..6a16c8e8238f 100644
> --- a/drivers/pci/hotplug/acpiphp_ibm.c
> +++ b/drivers/pci/hotplug/acpiphp_ibm.c
> @@ -140,11 +140,8 @@ static union apci_descriptor *ibm_slot_from_id(int id)
>                 ret = des;
>
>  ibm_slot_done:
> -       if (ret) {
> -               ret = kmalloc(sizeof(union apci_descriptor), GFP_KERNEL);
> -               if (ret)
> -                       memcpy(ret, des, sizeof(union apci_descriptor));
> -       }
> +       if (ret)
> +               ret = kmemdup(des, sizeof(union apci_descriptor), GFP_KERNEL);

Maybe do

        ret = kmemdup(des, sizeof(*des), GFP_KERNEL);

while at it?

>         kfree(table);
>         return ret;
>  }
> --

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ