.. | .. |
---|
68 | 68 | |
---|
69 | 69 | static int __hypfs_sprp_ioctl(void __user *user_area) |
---|
70 | 70 | { |
---|
71 | | - struct hypfs_diag304 diag304; |
---|
| 71 | + struct hypfs_diag304 *diag304; |
---|
72 | 72 | unsigned long cmd; |
---|
73 | 73 | void __user *udata; |
---|
74 | 74 | void *data; |
---|
75 | 75 | int rc; |
---|
76 | 76 | |
---|
77 | | - if (copy_from_user(&diag304, user_area, sizeof(diag304))) |
---|
78 | | - return -EFAULT; |
---|
79 | | - if ((diag304.args[0] >> 8) != 0 || diag304.args[1] > DIAG304_CMD_MAX) |
---|
80 | | - return -EINVAL; |
---|
81 | | - |
---|
| 77 | + rc = -ENOMEM; |
---|
82 | 78 | data = (void *) get_zeroed_page(GFP_KERNEL | GFP_DMA); |
---|
83 | | - if (!data) |
---|
84 | | - return -ENOMEM; |
---|
| 79 | + diag304 = kzalloc(sizeof(*diag304), GFP_KERNEL); |
---|
| 80 | + if (!data || !diag304) |
---|
| 81 | + goto out; |
---|
85 | 82 | |
---|
86 | | - udata = (void __user *)(unsigned long) diag304.data; |
---|
87 | | - if (diag304.args[1] == DIAG304_SET_WEIGHTS || |
---|
88 | | - diag304.args[1] == DIAG304_SET_CAPPING) |
---|
89 | | - if (copy_from_user(data, udata, PAGE_SIZE)) { |
---|
90 | | - rc = -EFAULT; |
---|
| 83 | + rc = -EFAULT; |
---|
| 84 | + if (copy_from_user(diag304, user_area, sizeof(*diag304))) |
---|
| 85 | + goto out; |
---|
| 86 | + rc = -EINVAL; |
---|
| 87 | + if ((diag304->args[0] >> 8) != 0 || diag304->args[1] > DIAG304_CMD_MAX) |
---|
| 88 | + goto out; |
---|
| 89 | + |
---|
| 90 | + rc = -EFAULT; |
---|
| 91 | + udata = (void __user *)(unsigned long) diag304->data; |
---|
| 92 | + if (diag304->args[1] == DIAG304_SET_WEIGHTS || |
---|
| 93 | + diag304->args[1] == DIAG304_SET_CAPPING) |
---|
| 94 | + if (copy_from_user(data, udata, PAGE_SIZE)) |
---|
91 | 95 | goto out; |
---|
92 | | - } |
---|
93 | 96 | |
---|
94 | | - cmd = *(unsigned long *) &diag304.args[0]; |
---|
95 | | - diag304.rc = hypfs_sprp_diag304(data, cmd); |
---|
| 97 | + cmd = *(unsigned long *) &diag304->args[0]; |
---|
| 98 | + diag304->rc = hypfs_sprp_diag304(data, cmd); |
---|
96 | 99 | |
---|
97 | | - if (diag304.args[1] == DIAG304_QUERY_PRP) |
---|
| 100 | + if (diag304->args[1] == DIAG304_QUERY_PRP) |
---|
98 | 101 | if (copy_to_user(udata, data, PAGE_SIZE)) { |
---|
99 | 102 | rc = -EFAULT; |
---|
100 | 103 | goto out; |
---|
101 | 104 | } |
---|
102 | 105 | |
---|
103 | | - rc = copy_to_user(user_area, &diag304, sizeof(diag304)) ? -EFAULT : 0; |
---|
| 106 | + rc = copy_to_user(user_area, diag304, sizeof(*diag304)) ? -EFAULT : 0; |
---|
104 | 107 | out: |
---|
| 108 | + kfree(diag304); |
---|
105 | 109 | free_page((unsigned long) data); |
---|
106 | 110 | return rc; |
---|
107 | 111 | } |
---|
.. | .. |
---|
133 | 137 | .unlocked_ioctl = hypfs_sprp_ioctl, |
---|
134 | 138 | }; |
---|
135 | 139 | |
---|
136 | | -int hypfs_sprp_init(void) |
---|
| 140 | +void hypfs_sprp_init(void) |
---|
137 | 141 | { |
---|
138 | 142 | if (!sclp.has_sprp) |
---|
139 | | - return 0; |
---|
140 | | - return hypfs_dbfs_create_file(&hypfs_sprp_file); |
---|
| 143 | + return; |
---|
| 144 | + hypfs_dbfs_create_file(&hypfs_sprp_file); |
---|
141 | 145 | } |
---|
142 | 146 | |
---|
143 | 147 | void hypfs_sprp_exit(void) |
---|