From 881dac8bcf7f6e26635fa38f071b93347ef92192 Mon Sep 17 00:00:00 2001 From: Venkatesh Srinivas Date: Fri, 10 Sep 2010 06:03:59 -0700 Subject: [PATCH] kernel - tmpfs: Set M_NULLOK on node allocations and safe node_init against null node pointers. Dragonfly-bug: Still 1726 (tmpfs malloc limit exceeded). --- sys/vfs/tmpfs/tmpfs_subr.c | 4 +++- sys/vfs/tmpfs/tmpfs_vfsops.c | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/sys/vfs/tmpfs/tmpfs_subr.c b/sys/vfs/tmpfs/tmpfs_subr.c index a77069efd4..55ae46222c 100644 --- a/sys/vfs/tmpfs/tmpfs_subr.c +++ b/sys/vfs/tmpfs/tmpfs_subr.c @@ -105,7 +105,9 @@ tmpfs_alloc_node(struct tmpfs_mount *tmp, enum vtype type, if (tmp->tm_nodes_inuse >= tmp->tm_nodes_max) return (ENOSPC); - nnode = (struct tmpfs_node *)objcache_get(tmp->tm_node_pool, M_WAITOK); + nnode = objcache_get(tmp->tm_node_pool, M_WAITOK | M_NULLOK); + if (nnode == NULL) + return (ENOSPC); /* Generic initialization. */ nnode->tn_type = type; diff --git a/sys/vfs/tmpfs/tmpfs_vfsops.c b/sys/vfs/tmpfs/tmpfs_vfsops.c index 9edc68eb3e..5ef89cb56b 100644 --- a/sys/vfs/tmpfs/tmpfs_vfsops.c +++ b/sys/vfs/tmpfs/tmpfs_vfsops.c @@ -106,6 +106,8 @@ static void* tmpfs_node_init(void *args, int flags) { struct tmpfs_node *node = (struct tmpfs_node *)objcache_malloc_alloc(args, flags); + if (node == NULL) + return (NULL); node->tn_id = 0; lockinit(&node->tn_interlock, "tmpfs node interlock", 0, LK_CANRECURSE); -- 2.41.0