|
24 | 24 | #include <linux/uaccess.h>
|
25 | 25 |
|
26 | 26 |
|
| 27 | +struct opal_prd_msg { |
| 28 | + union { |
| 29 | + struct opal_prd_msg_header header; |
| 30 | + DECLARE_FLEX_ARRAY(u8, data); |
| 31 | + }; |
| 32 | +}; |
| 33 | + |
27 | 34 | /*
|
28 | 35 | * The msg member must be at the end of the struct, as it's followed by the
|
29 | 36 | * message data.
|
30 | 37 | */
|
31 | 38 | struct opal_prd_msg_queue_item {
|
32 |
| - struct list_head list; |
33 |
| - struct opal_prd_msg_header msg; |
| 39 | + struct list_head list; |
| 40 | + struct opal_prd_msg msg; |
34 | 41 | };
|
35 | 42 |
|
36 | 43 | static struct device_node *prd_node;
|
@@ -156,7 +163,7 @@ static ssize_t opal_prd_read(struct file *file, char __user *buf,
|
156 | 163 | int rc;
|
157 | 164 |
|
158 | 165 | /* we need at least a header's worth of data */
|
159 |
| - if (count < sizeof(item->msg)) |
| 166 | + if (count < sizeof(item->msg.header)) |
160 | 167 | return -EINVAL;
|
161 | 168 |
|
162 | 169 | if (*ppos)
|
@@ -186,7 +193,7 @@ static ssize_t opal_prd_read(struct file *file, char __user *buf,
|
186 | 193 | return -EINTR;
|
187 | 194 | }
|
188 | 195 |
|
189 |
| - size = be16_to_cpu(item->msg.size); |
| 196 | + size = be16_to_cpu(item->msg.header.size); |
190 | 197 | if (size > count) {
|
191 | 198 | err = -EINVAL;
|
192 | 199 | goto err_requeue;
|
@@ -352,7 +359,7 @@ static int opal_prd_msg_notifier(struct notifier_block *nb,
|
352 | 359 | if (!item)
|
353 | 360 | return -ENOMEM;
|
354 | 361 |
|
355 |
| - memcpy(&item->msg, msg->params, msg_size); |
| 362 | + memcpy(&item->msg.data, msg->params, msg_size); |
356 | 363 |
|
357 | 364 | spin_lock_irqsave(&opal_prd_msg_queue_lock, flags);
|
358 | 365 | list_add_tail(&item->list, &opal_prd_msg_queue);
|
|
0 commit comments