Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/external/bsd/drm2/linux Tweak slightly sketchy logic in ...
details: https://anonhg.NetBSD.org/src/rev/3882db9e4f6d
branches: trunk
changeset: 355330:3882db9e4f6d
user: riastradh <riastradh%NetBSD.org@localhost>
date: Wed Jul 26 03:40:39 2017 +0000
description:
Tweak slightly sketchy logic in linux_idr.
1. idr_preload can fail if you don't set __GFP_WAIT.
2. If idr_preload fails, it is wrong for idr_alloc to assert.
3. There is no way for idr_alloc to know what flags idr_preload got.
Probably won't *fix* any bugs, but if there is a bug with a missing
__GFP_WAIT, then we will learn about a trifle sooner.
diffstat:
sys/external/bsd/drm2/linux/linux_idr.c | 11 +++++++----
1 files changed, 7 insertions(+), 4 deletions(-)
diffs (39 lines):
diff -r 2a05918c129c -r 3882db9e4f6d sys/external/bsd/drm2/linux/linux_idr.c
--- a/sys/external/bsd/drm2/linux/linux_idr.c Wed Jul 26 01:33:35 2017 +0000
+++ b/sys/external/bsd/drm2/linux/linux_idr.c Wed Jul 26 03:40:39 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: linux_idr.c,v 1.5 2015/01/01 01:15:43 mrg Exp $ */
+/* $NetBSD: linux_idr.c,v 1.6 2017/07/26 03:40:39 riastradh Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux_idr.c,v 1.5 2015/01/01 01:15:43 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_idr.c,v 1.6 2017/07/26 03:40:39 riastradh Exp $");
#include <sys/param.h>
#include <sys/atomic.h>
@@ -191,6 +191,7 @@
ASSERT_SLEEPABLE();
node = kmalloc(sizeof(*node), gfp);
+ KASSERT(node != NULL || !ISSET(gfp, __GFP_WAIT));
if (node == NULL)
return;
@@ -216,8 +217,10 @@
/* Grab a node allocated by idr_preload. */
mutex_spin_enter(&idr_cache.lock);
- KASSERTMSG(!SIMPLEQ_EMPTY(&idr_cache.preloaded_nodes),
- "missing call to idr_preload");
+ if (SIMPLEQ_EMPTY(&idr_cache.preloaded_nodes)) {
+ mutex_spin_exit(&idr_cache.lock);
+ return -ENOMEM;
+ }
node = SIMPLEQ_FIRST(&idr_cache.preloaded_nodes);
SIMPLEQ_REMOVE_HEAD(&idr_cache.preloaded_nodes, in_list);
mutex_spin_exit(&idr_cache.lock);
Home |
Main Index |
Thread Index |
Old Index