hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/arch/s390/hypfs/hypfs_sprp.c
....@@ -68,40 +68,44 @@
6868
6969 static int __hypfs_sprp_ioctl(void __user *user_area)
7070 {
71
- struct hypfs_diag304 diag304;
71
+ struct hypfs_diag304 *diag304;
7272 unsigned long cmd;
7373 void __user *udata;
7474 void *data;
7575 int rc;
7676
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;
8278 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;
8582
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))
9195 goto out;
92
- }
9396
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);
9699
97
- if (diag304.args[1] == DIAG304_QUERY_PRP)
100
+ if (diag304->args[1] == DIAG304_QUERY_PRP)
98101 if (copy_to_user(udata, data, PAGE_SIZE)) {
99102 rc = -EFAULT;
100103 goto out;
101104 }
102105
103
- rc = copy_to_user(user_area, &diag304, sizeof(diag304)) ? -EFAULT : 0;
106
+ rc = copy_to_user(user_area, diag304, sizeof(*diag304)) ? -EFAULT : 0;
104107 out:
108
+ kfree(diag304);
105109 free_page((unsigned long) data);
106110 return rc;
107111 }
....@@ -133,11 +137,11 @@
133137 .unlocked_ioctl = hypfs_sprp_ioctl,
134138 };
135139
136
-int hypfs_sprp_init(void)
140
+void hypfs_sprp_init(void)
137141 {
138142 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);
141145 }
142146
143147 void hypfs_sprp_exit(void)