Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1229179 > unrolled thread

[PATCH 3/3] drivers/misc/sgi-gru: fix return of error

Started bySudip Mukherjee <sudipm.mukherjee@gmail.com>
First post2015-09-21 12:20 +0200
Last post2015-09-21 12:20 +0200
Articles 1 — 1 participant

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH 3/3] drivers/misc/sgi-gru: fix return of error Sudip Mukherjee <sudipm.mukherjee@gmail.com> - 2015-09-21 12:20 +0200

#1229179 — [PATCH 3/3] drivers/misc/sgi-gru: fix return of error

FromSudip Mukherjee <sudipm.mukherjee@gmail.com>
Date2015-09-21 12:20 +0200
Subject[PATCH 3/3] drivers/misc/sgi-gru: fix return of error
Message-ID<qb6mt-3FW-15@gated-at.bofh.it>
If kzalloc() fails then gms is NULL and we are returning NULL, but the
functions which called this function gru_register_mmu_notifier() are not
expecting NULL as the return. They are expecting either a valid pointer
or the error code in ERR_PTR.

Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
---

The patch at https://patchwork.kernel.org/patch/6394911/ is not applied
and not relevant now as gms is checked before gru_dbg. But the idea for
this patch was obtained from that one.

 drivers/misc/sgi-gru/grutlbpurge.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/misc/sgi-gru/grutlbpurge.c b/drivers/misc/sgi-gru/grutlbpurge.c
index 757a8e9..e936d43 100644
--- a/drivers/misc/sgi-gru/grutlbpurge.c
+++ b/drivers/misc/sgi-gru/grutlbpurge.c
@@ -306,16 +306,16 @@ struct gru_mm_struct *gru_register_mmu_notifier(void)
 		atomic_inc(&gms->ms_refcnt);
 	} else {
 		gms = kzalloc(sizeof(*gms), GFP_KERNEL);
-		if (gms) {
-			STAT(gms_alloc);
-			spin_lock_init(&gms->ms_asid_lock);
-			gms->ms_notifier.ops = &gru_mmuops;
-			atomic_set(&gms->ms_refcnt, 1);
-			init_waitqueue_head(&gms->ms_wait_queue);
-			err = __mmu_notifier_register(&gms->ms_notifier, current->mm);
-			if (err)
-				goto error;
-		}
+		if (!gms)
+			return ERR_PTR(-ENOMEM);
+		STAT(gms_alloc);
+		spin_lock_init(&gms->ms_asid_lock);
+		gms->ms_notifier.ops = &gru_mmuops;
+		atomic_set(&gms->ms_refcnt, 1);
+		init_waitqueue_head(&gms->ms_wait_queue);
+		err = __mmu_notifier_register(&gms->ms_notifier, current->mm);
+		if (err)
+			goto error;
 	}
 	if (gms)
 		gru_dbg(grudev, "gms %p, refcnt %d\n", gms,
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web