Module Name: src
Committed By: jdolecek
Date: Sat Aug 12 15:08:38 UTC 2017
Modified Files:
src/sys/dev/ata [jdolecek-ncq]: ata.c
Log Message:
take atabus_qlock while inserting into atabus_initq_head to avoid race
in attach and rescan; just cleanup, noticed this while doing the thread
locking, don't think there is realistic way to trigger this
To generate a diff of this commit:
cvs rdiff -u -r1.132.8.26 -r1.132.8.27 src/sys/dev/ata/ata.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/dev/ata/ata.c
diff -u src/sys/dev/ata/ata.c:1.132.8.26 src/sys/dev/ata/ata.c:1.132.8.27
--- src/sys/dev/ata/ata.c:1.132.8.26 Sat Aug 12 14:41:54 2017
+++ src/sys/dev/ata/ata.c Sat Aug 12 15:08:38 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: ata.c,v 1.132.8.26 2017/08/12 14:41:54 jdolecek Exp $ */
+/* $NetBSD: ata.c,v 1.132.8.27 2017/08/12 15:08:38 jdolecek Exp $ */
/*
* Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved.
@@ -25,7 +25,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.132.8.26 2017/08/12 14:41:54 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.132.8.27 2017/08/12 15:08:38 jdolecek Exp $");
#include "opt_ata.h"
@@ -711,7 +711,9 @@ atabus_attach(device_t parent, device_t
initq = malloc(sizeof(*initq), M_DEVBUF, M_WAITOK);
initq->atabus_sc = sc;
+ mutex_enter(&atabus_qlock);
TAILQ_INSERT_TAIL(&atabus_initq_head, initq, atabus_initq);
+ mutex_exit(&atabus_qlock);
config_pending_incr(sc->sc_dev);
if ((error = kthread_create(PRI_NONE, 0, NULL, atabus_thread, sc,
@@ -2390,7 +2392,9 @@ atabus_rescan(device_t self, const char
initq = malloc(sizeof(*initq), M_DEVBUF, M_WAITOK);
initq->atabus_sc = sc;
+ mutex_enter(&atabus_qlock);
TAILQ_INSERT_TAIL(&atabus_initq_head, initq, atabus_initq);
+ mutex_exit(&atabus_qlock);
config_pending_incr(sc->sc_dev);
mutex_enter(&chp->ch_lock);