* [PATCH] arch: s390: use struct_size() in kmalloc()
@ 2019-05-17 7:15 xiaolinkui
2019-06-01 10:21 ` Heiko Carstens
0 siblings, 1 reply; 2+ messages in thread
From: xiaolinkui @ 2019-05-17 7:15 UTC (permalink / raw)
To: schwidefsky, heiko.carstens; +Cc: linux-s390, linux-kernel, xiaolinkui
Use the new struct_size() helper to keep code simple.
Signed-off-by: xiaolinkui <xiaolinkui@kylinos.cn>
---
arch/s390/include/asm/idals.h | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/arch/s390/include/asm/idals.h b/arch/s390/include/asm/idals.h
index 15578fd..6fb7ace 100644
--- a/arch/s390/include/asm/idals.h
+++ b/arch/s390/include/asm/idals.h
@@ -122,8 +122,7 @@ idal_buffer_alloc(size_t size, int page_order)
nr_ptrs = (size + IDA_BLOCK_SIZE - 1) >> IDA_SIZE_LOG;
nr_chunks = (4096 << page_order) >> IDA_SIZE_LOG;
- ib = kmalloc(sizeof(struct idal_buffer) + nr_ptrs*sizeof(void *),
- GFP_DMA | GFP_KERNEL);
+ ib = kmalloc(struct_size(ib, data, nr_ptrs), GFP_DMA | GFP_KERNEL);
if (ib == NULL)
return ERR_PTR(-ENOMEM);
ib->size = size;
--
2.7.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] arch: s390: use struct_size() in kmalloc()
2019-05-17 7:15 [PATCH] arch: s390: use struct_size() in kmalloc() xiaolinkui
@ 2019-06-01 10:21 ` Heiko Carstens
0 siblings, 0 replies; 2+ messages in thread
From: Heiko Carstens @ 2019-06-01 10:21 UTC (permalink / raw)
To: xiaolinkui; +Cc: linux-s390, linux-kernel
On Fri, May 17, 2019 at 03:15:17PM +0800, xiaolinkui wrote:
> Use the new struct_size() helper to keep code simple.
>
> Signed-off-by: xiaolinkui <xiaolinkui@kylinos.cn>
> ---
> arch/s390/include/asm/idals.h | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/arch/s390/include/asm/idals.h b/arch/s390/include/asm/idals.h
> index 15578fd..6fb7ace 100644
> --- a/arch/s390/include/asm/idals.h
> +++ b/arch/s390/include/asm/idals.h
> @@ -122,8 +122,7 @@ idal_buffer_alloc(size_t size, int page_order)
>
> nr_ptrs = (size + IDA_BLOCK_SIZE - 1) >> IDA_SIZE_LOG;
> nr_chunks = (4096 << page_order) >> IDA_SIZE_LOG;
> - ib = kmalloc(sizeof(struct idal_buffer) + nr_ptrs*sizeof(void *),
> - GFP_DMA | GFP_KERNEL);
> + ib = kmalloc(struct_size(ib, data, nr_ptrs), GFP_DMA | GFP_KERNEL);
> if (ib == NULL)
> return ERR_PTR(-ENOMEM);
> ib->size = size;
Applied, thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-06-01 10:21 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-05-17 7:15 [PATCH] arch: s390: use struct_size() in kmalloc() xiaolinkui
2019-06-01 10:21 ` Heiko Carstens
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox