On Mon, Aug 11, 2025 at 10:22 AM Liao Yuanhong <liaoyuanhong@xxxxxxxx> 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@xxxxxxxx> > --- > 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; > } > --