[PATCH] uml: fix modify_ldt - missing break in switch
[linux-2.6/mini2440.git] / arch / um / sys-i386 / ldt.c
blob36b5c2c13289fd900e96f48d87c667f552b49721
1 /*
2 * Copyright (C) 2001, 2002 Jeff Dike (jdike@karaya.com)
3 * Licensed under the GPL
4 */
6 #include "linux/config.h"
7 #include "linux/sched.h"
8 #include "linux/slab.h"
9 #include "linux/types.h"
10 #include "asm/uaccess.h"
11 #include "asm/ptrace.h"
12 #include "asm/smp.h"
13 #include "asm/ldt.h"
14 #include "choose-mode.h"
15 #include "kern.h"
16 #include "mode_kern.h"
18 #ifdef CONFIG_MODE_TT
20 extern int modify_ldt(int func, void *ptr, unsigned long bytecount);
22 static int do_modify_ldt_tt(int func, void *ptr, unsigned long bytecount)
24 return modify_ldt(func, ptr, bytecount);
27 #endif
29 #ifdef CONFIG_MODE_SKAS
31 #include "skas.h"
32 #include "skas_ptrace.h"
34 static int do_modify_ldt_skas(int func, void *ptr, unsigned long bytecount)
36 struct ptrace_ldt ldt;
37 u32 cpu;
38 int res;
40 ldt = ((struct ptrace_ldt) { .func = func,
41 .ptr = ptr,
42 .bytecount = bytecount });
44 cpu = get_cpu();
45 res = ptrace(PTRACE_LDT, userspace_pid[cpu], 0, (unsigned long) &ldt);
46 put_cpu();
48 return res;
50 #endif
52 int sys_modify_ldt(int func, void __user *ptr, unsigned long bytecount)
54 struct user_desc info;
55 int res = 0;
56 void *buf = NULL;
57 void *p = NULL; /* What we pass to host. */
59 switch(func){
60 case 1:
61 case 0x11: /* write_ldt */
62 /* Do this check now to avoid overflows. */
63 if (bytecount != sizeof(struct user_desc)) {
64 res = -EINVAL;
65 goto out;
68 if(copy_from_user(&info, ptr, sizeof(info))) {
69 res = -EFAULT;
70 goto out;
73 p = &info;
74 break;
75 case 0:
76 case 2: /* read_ldt */
78 /* The use of info avoids kmalloc on the write case, not on the
79 * read one. */
80 buf = kmalloc(bytecount, GFP_KERNEL);
81 if (!buf) {
82 res = -ENOMEM;
83 goto out;
85 p = buf;
86 break;
87 default:
88 res = -ENOSYS;
89 goto out;
92 res = CHOOSE_MODE_PROC(do_modify_ldt_tt, do_modify_ldt_skas, func,
93 p, bytecount);
94 if(res < 0)
95 goto out;
97 switch(func){
98 case 0:
99 case 2:
100 /* Modify_ldt was for reading and returned the number of read
101 * bytes.*/
102 if(copy_to_user(ptr, p, res))
103 res = -EFAULT;
104 break;
107 out:
108 kfree(buf);
109 return res;