13 Commits

Author SHA1 Message Date
Travis Geiselbrecht
f5999d5a40 Merge branch 'port_race_test' of github.com:redpig/lk
edit: add a few quickie warning fixes
2025-09-29 23:15:57 -07:00
Noah Woo
bea3787d6e [kernel][port] add a missing THREAD_UNLOCK call in port_group_remove()
port_group_remove() used to return without unlocking a thread if no
matching read port is found, which is not correct. This patch adds a
call to THREAD_UNLOCK before it returns ERR_BAD_HANDLE.
2025-01-03 20:52:08 -08:00
Travis Geiselbrecht
df32504748 [kernel] test run sorting some includes
No functional change.
2019-07-13 17:21:00 -07:00
Travis Geiselbrecht
85a50ea3f4 [kernel][license] try out using a smaller version of the license header
Replace the body of the MIT license with a reference to the LICENSE file
and a URL with the MIT license. Replaces 20 something lines with 3.

No functional change.
2019-06-19 23:28:14 -07:00
Travis Geiselbrecht
d8fa82cb91 [formatting] run everything through codestyle
Almost nothing changes here except moving braces to the same line as the
function declaration. Everything else is largely whitespace changes and
a few dangling files with tab indents.

See scripts/codestyle
2019-06-19 21:02:24 -07:00
Travis Geiselbrecht
1b7a28efb8 [include][lk] fixup lk/ include path move 2019-06-19 19:46:11 -07:00
Will Drewry
cf3b7a15df kernel/port.c: make make_buf() safe
make_buf() is a static function with two callers who pass in one of
two constants. The parameters allowed for any uint count to be
supplied and the arithmetic during memory allocation was unchecked

This change updates make_buf() to reflect its usage, which is
safe, while eliminating any future uses from accidentally becoming
unsafe.
2017-12-22 13:52:43 -08:00
Will Drewry
e08ca47ff1 kernel/port.c: protect against port_create() race
In the current design, ports may be created with the same name
because of time-of-check-time-of-use behavior.

This change adds a new port magic, PORTHOLD_MAGIC, which cannot be
accessed using the normal accessors. It is injected into the list
upon a successful, locked search for a name.  It holds the name
until the allocation happens. At which point the port-hold is
deleted and the real port is added while, again, under the thread
lock.

This change assumes using a stack-allocated port is desirable over
preallocating and freeing on each port_create().  If the overhead
of allocation is low, then pre-allocating the new port would be
the cleanest option: (1) allocate, (2) check for collisions,
(3) add to list.

This fix is confirmed by the two_threads_race test completing its
256 iterations without a race. It also fixes the test to expect
ERR_BUSY and to exit cleanly, as it had never completed before.
2017-12-22 15:10:42 -06:00
Gurjant Kalsi
42e76b1fc7 [ports] Add an API to dynamically add/remove ports from a port group. 2016-02-23 14:23:25 -08:00
Travis Geiselbrecht
2eb32a4369 [style] mass reformat all the non external code to 4 space indents
Ran everything through scripts/codestyle.space, which uses astyle
to generally follow K&R style.

Biggest non whitespace change is pulling brackets down on function
declarations, which I'm pretty ambivalent about, but astyle insists
on taking a stance
2016-02-14 12:24:01 -08:00
Gurjant Kalsi
52f4728c44 [magic][constants] Convert all of LK's multichar character kernel magic constants to hex. 2016-02-09 15:02:05 -08:00
Carlos Pizano
6cdc5cd1da [kernel][port] Fix memory leak on port_open() 2015-11-23 12:38:40 -08:00
Carlos Pizano
614eaf166a [kernel][ports] Add basic ports functionality
Missing mostly more tests, specifically group tests.

BUG=none
R=travisg@google.com

Review URL: https://codereview.chromium.org/1437453002 .
2015-11-20 14:43:27 -08:00