Commit df8c0b8a authored by Javier Carrasco's avatar Javier Carrasco Committed by Johan Hovold

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: default avatarNathan Chancellor <nathan@kernel.org>
Signed-off-by: default avatarJavier Carrasco <javier.carrasco.cruz@gmail.com>
Reviewed-by: default avatarGustavo A. R. Silva <gustavoars@kernel.org>
Reviewed-by: default avatarKees Cook <kees@kernel.org>
Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
parent 55a15b3a
......@@ -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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment