littlekernel / lk

LK embedded kernel
MIT License
3.12k stars 613 forks source link

kernel/port.c: make make_buf() safe #214

Closed redpig closed 6 years ago

redpig commented 6 years ago

make_buf() is a static function with two callers that pass in one of two constants. The parameters allowed for any uint count to be supplied and the arithmetic during memory allocation is unchecked.

This change updates make_buf() prototype to reflect its usage, which is safe, while eliminating any future uses from accidentally becoming unsafe. It does so by changing the parameter as a boolean that decides between a big or a small port buffer.

travisg commented 6 years ago

LGTM