hulk inclusion category: bugfix bugzilla: https://atomgit.com/openeuler/kernel/issues/8423 -------------------------------- Move quota_timeout hrtimer access after the NULL check on xg to avoid possible dereference of a null pointer. This ensures safe early return when xg is invalid. Fixes: aafde051ac61 ("xsched: Add support for CFS quota for cgroups") Signed-off-by: Liu Kai <liukai284@huawei.com> --- kernel/xsched/cfs_quota.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/kernel/xsched/cfs_quota.c b/kernel/xsched/cfs_quota.c index fb4cca6a62f4..591b22968024 100644 --- a/kernel/xsched/cfs_quota.c +++ b/kernel/xsched/cfs_quota.c @@ -137,13 +137,14 @@ void xsched_quota_timeout_init(struct xsched_group *xg) void xsched_quota_timeout_update(struct xsched_group *xg) { - struct hrtimer *t = &xg->quota_timeout; - - hrtimer_cancel(t); + struct hrtimer *t; if (!xg) return; + t = &xg->quota_timeout; + hrtimer_cancel(t); + if (xg->quota > 0 && xg->period > 0) hrtimer_start(t, ns_to_ktime(xg->period), HRTIMER_MODE_REL_SOFT); else -- 2.34.1