Message ID | 20230815092434.1206386-1-ruanjinjie@huawei.com (mailing list archive) |
---|---|
State | Accepted |
Commit | 71281ec9c82608c42d6841a75ced97aecd4274be |
Headers | show |
Series | [-next] xen: Switch to use kmemdup() helper | expand |
On 15.08.23 11:24, Ruan Jinjie wrote: > Use kmemdup() helper instead of open-coding to > simplify the code. > > Signed-off-by: Ruan Jinjie <ruanjinjie@huawei.com> Reviewed-by: Juergen Gross <jgross@suse.com> with one nit ... > --- > drivers/xen/xen-acpi-processor.c | 7 ++----- > 1 file changed, 2 insertions(+), 5 deletions(-) > > diff --git a/drivers/xen/xen-acpi-processor.c b/drivers/xen/xen-acpi-processor.c > index 9cb61db67efd..e4be543987a5 100644 > --- a/drivers/xen/xen-acpi-processor.c > +++ b/drivers/xen/xen-acpi-processor.c > @@ -473,11 +473,8 @@ static int xen_upload_processor_pm_data(void) > if (!_pr) > continue; > > - if (!pr_backup) { > - pr_backup = kzalloc(sizeof(struct acpi_processor), GFP_KERNEL); > - if (pr_backup) > - memcpy(pr_backup, _pr, sizeof(struct acpi_processor)); > - } > + if (!pr_backup) > + pr_backup = kmemdup(_pr, sizeof(struct acpi_processor), GFP_KERNEL); As you are touching it, I'd prefer sizeof(*_pr) instead of sizeof(struct acpi_processor). I can do that change while committing, if you are fine with it. Juergen
On 15.08.23 11:24, Ruan Jinjie wrote: > Use kmemdup() helper instead of open-coding to > simplify the code. > > Signed-off-by: Ruan Jinjie <ruanjinjie@huawei.com> Pushed to xen/tip.git for-linus-6.6 Juergen
diff --git a/drivers/xen/xen-acpi-processor.c b/drivers/xen/xen-acpi-processor.c index 9cb61db67efd..e4be543987a5 100644 --- a/drivers/xen/xen-acpi-processor.c +++ b/drivers/xen/xen-acpi-processor.c @@ -473,11 +473,8 @@ static int xen_upload_processor_pm_data(void) if (!_pr) continue; - if (!pr_backup) { - pr_backup = kzalloc(sizeof(struct acpi_processor), GFP_KERNEL); - if (pr_backup) - memcpy(pr_backup, _pr, sizeof(struct acpi_processor)); - } + if (!pr_backup) + pr_backup = kmemdup(_pr, sizeof(struct acpi_processor), GFP_KERNEL); (void)upload_pm_data(_pr); }
Use kmemdup() helper instead of open-coding to simplify the code. Signed-off-by: Ruan Jinjie <ruanjinjie@huawei.com> --- drivers/xen/xen-acpi-processor.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)