⬢ DragonFlyBSD Kernel Audit
DF-4252 / fix.diff
← back to finding ↓ download raw
--- a/sys/dev/raid/mpr/mpr_sas_lsi.c
+++ b/sys/dev/raid/mpr/mpr_sas_lsi.c
@@ -324,11 +324,19 @@
 				Mpi2RaidActionReply_t *reply = NULL;
 				struct mpr_command *cm;
 				int error = 0;
-				if ((cm = mpr_alloc_command(sc)) == NULL) {
-					kprintf("%s: command alloc failed\n",
-					    __func__);
-					return;
-				}
+			if ((cm = mpr_alloc_command(sc)) == NULL) {
+				kprintf("%s: command alloc failed\n",
+				    __func__);
+				/*
+				 * Must still drop the startup refcount taken
+				 * in mprsas_evt_handler() and free this
+				 * event, or the fw_event allocation leaks
+				 * and discovery can never complete.
+				 */
+				mprsas_startup_decrement(sassc);
+				mprsas_fw_event_free(sc, fw_event);
+				return;
+			}
 
 				mpr_dprint(sc, MPR_EVENT, "Sending FP action "
 				    "from "