diff --git a/NEWS b/NEWS
index 318874e4cd0d282be71d6fea790fcd12bca51998..e665a68a91e6993a207f8cfec3630e4be4fc8081 100644
--- a/NEWS
+++ b/NEWS
@@ -21,6 +21,7 @@ documents those changes that are of interest to users and admins.
  -- Avoid orphan job step if slurmctld is down when a job step completes.
  -- Fix Lua link order, patch from Pär Andersson, NSC.
  -- Set SLURM_CPUS_PER_TASK=1 when user specifies --cpus-per-task=1.
+ -- Fix for fatal error managing GRES. Patch by Carles Fenoy, BSC.
 
 * Changes in SLURM 2.3.1
 ========================
diff --git a/doc/html/team.shtml b/doc/html/team.shtml
index f0ad3cac7aa49bcc91ffb472b859dc1fdeef1723..4a1b1d07e0e59edea55a2413dee286dcb409d1c3 100644
--- a/doc/html/team.shtml
+++ b/doc/html/team.shtml
@@ -27,6 +27,7 @@ organizations. The current SLURM development staff includes: </p>
 <li>Gilles Civario (Bull)</li>
 <li>Chuck Clouston (Bull)</li>
 <li>Yuri D'Elia (Center for Biomedicine, EURAC Research, Italy)</li>
+<li>Carles Fenoy (Barcelona Supercomputer Center, Spain)</li>
 <li>Joseph Donaghy (LLNL)</li>
 <li>Chris Dunlap (LLNL)</li>
 <li>Joey Ekstrom (LLNL/Bringham Young University)</li>
diff --git a/src/common/gres.c b/src/common/gres.c
index c1e2ecc7116530ce2ffa7d8618046b2211fbc737..a0e4523e32278aa44aded12c4c6615762a77d71d 100644
--- a/src/common/gres.c
+++ b/src/common/gres.c
@@ -2509,6 +2509,12 @@ extern uint32_t _job_test(void *job_gres_data, void *node_gres_data,
 		return NO_VAL;
 	} else if (job_gres_ptr->gres_cnt_alloc && node_gres_ptr->topo_cnt) {
 		/* Need to determine which specific CPUs can be used */
+		gres_avail = node_gres_ptr->gres_cnt_avail;
+		if (!use_total_gres)
+			gres_avail -= node_gres_ptr->gres_cnt_alloc;
+		if (job_gres_ptr->gres_cnt_alloc > gres_avail)
+			return (uint32_t) 0;	/* insufficient, gres to use */
+
 		if (cpu_bitmap) {
 			cpus_ctld = cpu_end_bit - cpu_start_bit + 1;
 			if (cpus_ctld < 1) {