Skip to content

Commit 0fcc4c8

Browse files
thejhhtejun
authored andcommitted
device_cgroup: fix RCU imbalance in error case
When dev_exception_add() returns an error (due to a failed memory allocation), make sure that we move the RCU preemption count back to where it was before we were called. We dropped the RCU read lock inside the loop body, so we can't just "break". sparse complains about this, too: $ make -s C=2 security/device_cgroup.o ./include/linux/rcupdate.h:647:9: warning: context imbalance in 'propagate_exception' - unexpected unlock Fixes: d591fb5 ("device_cgroup: simplify cgroup tree walk in propagate_exception()") Cc: stable@vger.kernel.org Signed-off-by: Jann Horn <jannh@google.com> Acked-by: Michal Hocko <mhocko@suse.com> Signed-off-by: Tejun Heo <tj@kernel.org>
1 parent 9e98c67 commit 0fcc4c8

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎security/device_cgroup.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@ static int propagate_exception(struct dev_cgroup *devcg_root,
560560
devcg->behavior == DEVCG_DEFAULT_ALLOW) {
561561
rc = dev_exception_add(devcg, ex);
562562
if (rc)
563-
break;
563+
return rc;
564564
} else {
565565
/*
566566
* in the other possible cases:

0 commit comments

Comments
 (0)