diff --git a/NEWS b/NEWS
index fd51f887d2a03ec1d449fe154762b8aa42bbebee..a3fde504e9315694cffae6a9600c50f9c6bbc7ee 100644
--- a/NEWS
+++ b/NEWS
@@ -76,6 +76,8 @@ documents those changes that are of interest to users and admins.
  -- BGQ - fix for handling half rack system in STATIC of OVERLAP mode to
     implicitly create full system block.
  -- CRAY - Dynamically create BASIL XML buffer to resize as needed.
+ -- Fix checking if QOS limit MaxCPUMinsPJ is set along with DenyOnLimit to
+    deny the job instead of holding it.
 
 * Changes in Slurm 2.5.4
 ========================
diff --git a/src/slurmctld/acct_policy.c b/src/slurmctld/acct_policy.c
index 85d638d5658c5b05aba636d713fd3109f7c36850..24516713cf3972b4a0a364a7502a905153533593 100644
--- a/src/slurmctld/acct_policy.c
+++ b/src/slurmctld/acct_policy.c
@@ -647,23 +647,22 @@ extern bool acct_policy_validate(job_desc_msg_t *job_desc,
 		 * if you can end up in PENDING QOSJobLimit, you need
 		 * to validate it if DenyOnLimit is set
 		 */
-		if (qos_ptr->max_cpu_mins_pj != INFINITE) {
+		if (strict_checking && (qos_ptr->max_cpu_mins_pj != INFINITE)
+		    && (job_desc->time_limit != NO_VAL)
+		    && (job_desc->min_cpus != NO_VAL)) {
 			cpu_time_limit = qos_ptr->max_cpu_mins_pj;
 			job_cpu_time_limit = (uint64_t)job_desc->time_limit
-					* (uint64_t)job_desc->min_cpus;
-			if (strict_checking && (job_desc->time_limit != NO_VAL) &&
-					(job_cpu_time_limit > cpu_time_limit)) {
-					if (reason)
-						*reason = WAIT_QOS_JOB_LIMIT;
-					debug2("job submit for user %s(%u): "
-								"cpu time limit %"PRIu64" exceeds "
-								"qos max per-job %"PRIu64"",
-								user_name,
-								job_desc->user_id,
-								job_cpu_time_limit,
-								cpu_time_limit);
-					rc = false;
-					goto end_it;
+				* (uint64_t)job_desc->min_cpus;
+			if (job_cpu_time_limit > cpu_time_limit) {
+				if (reason)
+					*reason = WAIT_QOS_JOB_LIMIT;
+				debug2("job submit for user %s(%u): "
+				       "cpu time limit %"PRIu64" exceeds "
+				       "qos max per-job %"PRIu64"",
+				       user_name, job_desc->user_id,
+				       job_cpu_time_limit, cpu_time_limit);
+				rc = false;
+				goto end_it;
 			}
 		}