From: Felix Schlepper Date: Fri, 24 Jun 2022 13:54:53 +0000 (+0200) Subject: Staging: rtl8192e: Use struct_size X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=71eac0c07c7b26063bf5ee14a082e05421688552;p=linux.git Staging: rtl8192e: Use struct_size Using struct_size is encouraged because it is safer than using sizeof and calculations by hand. Signed-off-by: Felix Schlepper Link: https://lore.kernel.org/r/54ea62a2b7628d3bdd5aa52df82c3e91704a2127.1656078068.git.f3sch.git@outlook.com Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/rtl8192e/rtllib_tx.c b/drivers/staging/rtl8192e/rtllib_tx.c index 37715afb0210d..f2ef32e943ae8 100644 --- a/drivers/staging/rtl8192e/rtllib_tx.c +++ b/drivers/staging/rtl8192e/rtllib_tx.c @@ -205,8 +205,7 @@ static struct rtllib_txb *rtllib_alloc_txb(int nr_frags, int txb_size, struct rtllib_txb *txb; int i; - txb = kmalloc(sizeof(struct rtllib_txb) + (sizeof(u8 *) * nr_frags), - gfp_mask); + txb = kmalloc(struct_size(txb, fragments, nr_frags), gfp_mask); if (!txb) return NULL;