OSDN Git Service

apparmor: Fix unpack_profile() warn: passing zero to 'ERR_PTR'
authorJohn Johansen <john.johansen@canonical.com>
Mon, 10 Oct 2022 19:15:10 +0000 (12:15 -0700)
committerJohn Johansen <john.johansen@canonical.com>
Tue, 11 Oct 2022 00:17:19 +0000 (17:17 -0700)
commit53991aedcd34760be23f1b0ef312e39b6add84af
tree608588c6eed0174e0f2c7e949ad88b4f41bf25e6
parentee21a175ecfa821b74822881d354c7f848930738
apparmor: Fix unpack_profile() warn: passing zero to 'ERR_PTR'

unpack_profile() sets a default error on entry but this gets overridden
by error assignment by functions called in its body. If an error
check that was relying on the default value is triggered after one
of these error assignments then zero will be passed to ERR_PTR.

Fix this by setting up a default -EPROTO assignment in the error
path and while we are at it make sure the correct error is returned
in non-default cases.

Fixes: 217af7e2f4de ("apparmor: refactor profile rules and attachments")
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: John Johansen <john.johansen@canonical.com>
security/apparmor/policy_unpack.c