[PATCH] lguest: make sure cpu is initialized before accessing it

Previous thread: [PATCH 8/8][for -mm] mem_notify v6: support fasync feature by KOSAKI Motohiro on Saturday, February 9, 2008 - 11:28 am. (1 message)

Next thread: [sample] mem_notify v6: usage example by KOSAKI Motohiro on Saturday, February 9, 2008 - 11:55 am. (6 messages)
To: Rusty Russell <rusty@...>
Cc: <linux-kernel@...>, <lguest@...>
Date: Saturday, February 9, 2008 - 11:53 am

If req is LHREQ_INITIALIZE, and the guest has been initialized before
(unlikely), it will attempt to access cpu->tsk even though cpu is not yet
initialized.

Signed-off-by: Eugene Teo <eugeneteo@kernel.sg>
---
drivers/lguest/lguest_user.c | 14 +++++++-------
1 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/lguest/lguest_user.c b/drivers/lguest/lguest_user.c
index 85d42d3..9cbb285 100644
--- a/drivers/lguest/lguest_user.c
+++ b/drivers/lguest/lguest_user.c
@@ -241,15 +241,15 @@ static ssize_t write(struct file *file, const char __user *in,
cpu = &lg->cpus[cpu_id];
if (!cpu)
return -EINVAL;
- }

- /* Once the Guest is dead, all you can do is read() why it died. */
- if (lg && lg->dead)
- return -ENOENT;
+ /* Once the Guest is dead, all you can do is read() why it died. */
+ if (lg && lg->dead)
+ return -ENOENT;

- /* If you're not the task which owns the Guest, you can only break */
- if (lg && current != cpu->tsk && req != LHREQ_BREAK)
- return -EPERM;
+ /* If you're not the task which owns the Guest, you can only break */
+ if (lg && current != cpu->tsk && req != LHREQ_BREAK)
+ return -EPERM;
+ }

switch (req) {
case LHREQ_INITIALIZE:

--

Previous thread: [PATCH 8/8][for -mm] mem_notify v6: support fasync feature by KOSAKI Motohiro on Saturday, February 9, 2008 - 11:28 am. (1 message)

Next thread: [sample] mem_notify v6: usage example by KOSAKI Motohiro on Saturday, February 9, 2008 - 11:55 am. (6 messages)