8000 handle error case · ymm238/Linux-Kernel-Programming@5e5783e · GitHub
[go: up one dir, main page]

Skip to content

Commit 5e5783e

Browse files
committed
handle error case
1 parent 9b14208 commit 5e5783e

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

ch9/slab_custom/slab_custom.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ struct myctx {
4949
};
5050
static struct kmem_cache *gctx_cachep;
5151

52-
static void use_our_cache(void)
52+
static int use_our_cache(void)
5353
{
5454
struct myctx *obj = NULL;
5555

@@ -62,6 +62,7 @@ static void use_our_cache(void)
6262
obj = kmem_cache_alloc(gctx_cachep, GFP_KERNEL);
6363
if (!obj) { /* pedantic warning printk below... */
6464
pr_warn("kmem_cache_alloc() failed\n");
65+
return -ENOMEM;
6566
}
6667

6768
pr_info("Our cache object (@ %pK, actual=%px) size is %u bytes; actual ksize=%zu\n",
@@ -70,6 +71,7 @@ static void use_our_cache(void)
7071

7172
/* free it */
7273
kmem_cache_free(gctx_cachep, obj);
74+
return 0;
7375
}
7476

7577
/* The parameter is the pointer to the just allocated memory 'object' from

0 commit comments

Comments
 (0)
0