mirror of
https://github.com/torvalds/linux.git
synced 2026-05-27 00:22:00 +02:00
USB: serial: garmin_gps: use struct_size() to allocate pkt
Use the struct_size macro to calculate the size of the pkt, which includes a trailing flexible array. Suggested-by: Nathan Chancellor <nathan@kernel.org> Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com> Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org> Reviewed-by: Kees Cook <kees@kernel.org> Signed-off-by: Johan Hovold <johan@kernel.org>
This commit is contained in:
parent
55a15b3a71
commit
df8c0b8a03
|
|
@ -267,8 +267,7 @@ static int pkt_add(struct garmin_data *garmin_data_p,
|
|||
|
||||
/* process only packets containing data ... */
|
||||
if (data_length) {
|
||||
pkt = kmalloc(sizeof(struct garmin_packet)+data_length,
|
||||
GFP_ATOMIC);
|
||||
pkt = kmalloc(struct_size(pkt, data, data_length), GFP_ATOMIC);
|
||||
if (!pkt)
|
||||
return 0;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user