]> git.baikalelectronics.ru Git - kernel.git/commit
livepatch: Proper error handling in the shadow variables selftest
authorPetr Mladek <pmladek@suse.com>
Mon, 4 Feb 2019 13:56:52 +0000 (14:56 +0100)
committerPetr Mladek <pmladek@suse.com>
Wed, 6 Feb 2019 10:01:57 +0000 (11:01 +0100)
commit684b97547166bd7590ef9005bf795310db5d86c5
tree282f204261746a62ef583584cc0e5e66a2283a4a
parent1893c98d644f25868148da26c604fcefc76773cd
livepatch: Proper error handling in the shadow variables selftest

Add proper error handling when allocating or getting shadow variables
in the selftest. It prevents an invalid pointer access in some situations.
It shows the good programming practice in the others.

The error codes are just the best guess and specific for this particular
test. In general, klp_shadow_alloc() returns NULL also when the given
shadow variable has already been allocated. In addition, both
klp_shadow_alloc() and klp_shadow_get_or_alloc() might fail from
other reasons when the constructor fails.

Note, that the error code is not really important even in the real life.
The use of shadow variables should be transparent for the original
livepatched code.

Acked-by: Miroslav Benes <mbenes@suse.cz>
Acked-by: Joe Lawrence <joe.lawrence@redhat.com>
Signed-off-by: Petr Mladek <pmladek@suse.com>
lib/livepatch/test_klp_shadow_vars.c