diff options
Diffstat (limited to 'drivers/s390/char/sclp_async.c')
-rw-r--r-- | drivers/s390/char/sclp_async.c | 47 |
1 files changed, 18 insertions, 29 deletions
diff --git a/drivers/s390/char/sclp_async.c b/drivers/s390/char/sclp_async.c index a4f68e5b9c96..b44462a6c6d3 100644 --- a/drivers/s390/char/sclp_async.c +++ b/drivers/s390/char/sclp_async.c | |||
@@ -26,7 +26,6 @@ static struct sclp_async_sccb *sccb; | |||
26 | static int sclp_async_send_wait(char *message); | 26 | static int sclp_async_send_wait(char *message); |
27 | static struct ctl_table_header *callhome_sysctl_header; | 27 | static struct ctl_table_header *callhome_sysctl_header; |
28 | static DEFINE_SPINLOCK(sclp_async_lock); | 28 | static DEFINE_SPINLOCK(sclp_async_lock); |
29 | static char nodename[64]; | ||
30 | #define SCLP_NORMAL_WRITE 0x00 | 29 | #define SCLP_NORMAL_WRITE 0x00 |
31 | 30 | ||
32 | struct async_evbuf { | 31 | struct async_evbuf { |
@@ -52,9 +51,10 @@ static struct sclp_register sclp_async_register = { | |||
52 | static int call_home_on_panic(struct notifier_block *self, | 51 | static int call_home_on_panic(struct notifier_block *self, |
53 | unsigned long event, void *data) | 52 | unsigned long event, void *data) |
54 | { | 53 | { |
55 | strncat(data, nodename, strlen(nodename)); | 54 | strncat(data, init_utsname()->nodename, |
56 | sclp_async_send_wait(data); | 55 | sizeof(init_utsname()->nodename)); |
57 | return NOTIFY_DONE; | 56 | sclp_async_send_wait(data); |
57 | return NOTIFY_DONE; | ||
58 | } | 58 | } |
59 | 59 | ||
60 | static struct notifier_block call_home_panic_nb = { | 60 | static struct notifier_block call_home_panic_nb = { |
@@ -68,15 +68,14 @@ static int proc_handler_callhome(struct ctl_table *ctl, int write, | |||
68 | { | 68 | { |
69 | unsigned long val; | 69 | unsigned long val; |
70 | int len, rc; | 70 | int len, rc; |
71 | char buf[2]; | 71 | char buf[3]; |
72 | 72 | ||
73 | if (!*count | (*ppos && !write)) { | 73 | if (!*count || (*ppos && !write)) { |
74 | *count = 0; | 74 | *count = 0; |
75 | return 0; | 75 | return 0; |
76 | } | 76 | } |
77 | if (!write) { | 77 | if (!write) { |
78 | len = sprintf(buf, "%d\n", callhome_enabled); | 78 | len = snprintf(buf, sizeof(buf), "%d\n", callhome_enabled); |
79 | buf[len] = '\0'; | ||
80 | rc = copy_to_user(buffer, buf, sizeof(buf)); | 79 | rc = copy_to_user(buffer, buf, sizeof(buf)); |
81 | if (rc != 0) | 80 | if (rc != 0) |
82 | return -EFAULT; | 81 | return -EFAULT; |
@@ -171,39 +170,29 @@ static int __init sclp_async_init(void) | |||
171 | rc = sclp_register(&sclp_async_register); | 170 | rc = sclp_register(&sclp_async_register); |
172 | if (rc) | 171 | if (rc) |
173 | return rc; | 172 | return rc; |
174 | callhome_sysctl_header = register_sysctl_table(kern_dir_table); | 173 | rc = -EOPNOTSUPP; |
175 | if (!callhome_sysctl_header) { | 174 | if (!(sclp_async_register.sclp_receive_mask & EVTYP_ASYNC_MASK)) |
176 | rc = -ENOMEM; | ||
177 | goto out_sclp; | ||
178 | } | ||
179 | if (!(sclp_async_register.sclp_receive_mask & EVTYP_ASYNC_MASK)) { | ||
180 | rc = -EOPNOTSUPP; | ||
181 | goto out_sclp; | 175 | goto out_sclp; |
182 | } | ||
183 | rc = -ENOMEM; | 176 | rc = -ENOMEM; |
177 | callhome_sysctl_header = register_sysctl_table(kern_dir_table); | ||
178 | if (!callhome_sysctl_header) | ||
179 | goto out_sclp; | ||
184 | request = kzalloc(sizeof(struct sclp_req), GFP_KERNEL); | 180 | request = kzalloc(sizeof(struct sclp_req), GFP_KERNEL); |
185 | if (!request) | ||
186 | goto out_sys; | ||
187 | sccb = (struct sclp_async_sccb *) get_zeroed_page(GFP_KERNEL | GFP_DMA); | 181 | sccb = (struct sclp_async_sccb *) get_zeroed_page(GFP_KERNEL | GFP_DMA); |
188 | if (!sccb) | 182 | if (!request || !sccb) |
189 | goto out_mem; | 183 | goto out_mem; |
190 | rc = atomic_notifier_chain_register(&panic_notifier_list, | 184 | rc = atomic_notifier_chain_register(&panic_notifier_list, |
191 | &call_home_panic_nb); | 185 | &call_home_panic_nb); |
192 | if (rc) | 186 | if (!rc) |
193 | goto out_mem; | 187 | goto out; |
194 | |||
195 | strncpy(nodename, init_utsname()->nodename, 64); | ||
196 | return 0; | ||
197 | |||
198 | out_mem: | 188 | out_mem: |
199 | kfree(request); | 189 | kfree(request); |
200 | free_page((unsigned long) sccb); | 190 | free_page((unsigned long) sccb); |
201 | out_sys: | ||
202 | unregister_sysctl_table(callhome_sysctl_header); | 191 | unregister_sysctl_table(callhome_sysctl_header); |
203 | out_sclp: | 192 | out_sclp: |
204 | sclp_unregister(&sclp_async_register); | 193 | sclp_unregister(&sclp_async_register); |
194 | out: | ||
205 | return rc; | 195 | return rc; |
206 | |||
207 | } | 196 | } |
208 | module_init(sclp_async_init); | 197 | module_init(sclp_async_init); |
209 | 198 | ||