[PATCH nfsd] SQUASH 8dc9e02aed76 lib: add light-weight queuing mechanism.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Remove assumption that kmalloc never fails.

Signed-off-by: NeilBrown <neilb@xxxxxxx>
---

Hi Chuck,
 please squash this into the relevant patch - thanks.
Hi Dan,
 thanks for the review!

NeilBrown

 lib/lwq.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/lib/lwq.c b/lib/lwq.c
index 8a723b29b39e..57d080a4d53d 100644
--- a/lib/lwq.c
+++ b/lib/lwq.c
@@ -111,6 +111,8 @@ static int lwq_test(void)
 		threads[i] = kthread_run(lwq_exercise, &q, "lwq-test-%d", i);
 	for (i = 0; i < 100; i++) {
 		t = kmalloc(sizeof(*t), GFP_KERNEL);
+		if (!t)
+			break;
 		t->i = i;
 		t->c = 0;
 		if (lwq_enqueue(&t->n, &q))
@@ -127,7 +129,8 @@ static int lwq_test(void)
 			printk(KERN_INFO " lwq: ... ");
 		}
 		t = lwq_dequeue(&q, struct tnode, n);
-		printk(KERN_CONT " %d(%d)", t->i, t->c);
+		if (t)
+			printk(KERN_CONT " %d(%d)", t->i, t->c);
 		kfree(t);
 	}
 	printk(KERN_CONT "\n");
-- 
2.42.0




[Index of Archives]     [Linux Filesystem Development]     [Linux USB Development]     [Linux Media Development]     [Video for Linux]     [Linux NILFS]     [Linux Audio Users]     [Yosemite Info]     [Linux SCSI]

  Powered by Linux