[PATCH] hpet: Fix struct_size() in kzalloc()

From: Tetsuo Handa
Date: Wed Jan 29 2020 - 23:43:23 EST


Changing "struct hpet_dev hp_dev[1]" to "struct hpet_dev hp_dev[]"
reduces structure size by sizeof(struct hpet_dev) bytes. We need to
compensate it at struct_size().

Signed-off-by: Tetsuo Handa <penguin-kernel@xxxxxxxxxxxxxxxxxxx>
Fixes: 987f028b8637cfa7 ("char: hpet: Use flexible-array member")
---
drivers/char/hpet.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
index aed2c45f7968..ed3b7dab678d 100644
--- a/drivers/char/hpet.c
+++ b/drivers/char/hpet.c
@@ -855,7 +855,7 @@ int hpet_alloc(struct hpet_data *hdp)
return 0;
}

- hpetp = kzalloc(struct_size(hpetp, hp_dev, hdp->hd_nirqs - 1),
+ hpetp = kzalloc(struct_size(hpetp, hp_dev, hdp->hd_nirqs),
GFP_KERNEL);

if (!hpetp)
--
2.11.0