diff options
Diffstat (limited to 'drivers/md/dm-log-userspace-transfer.c')
-rw-r--r-- | drivers/md/dm-log-userspace-transfer.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/drivers/md/dm-log-userspace-transfer.c b/drivers/md/dm-log-userspace-transfer.c index 54abf9e303b7..075cbcf8a9f5 100644 --- a/drivers/md/dm-log-userspace-transfer.c +++ b/drivers/md/dm-log-userspace-transfer.c | |||
@@ -6,6 +6,7 @@ | |||
6 | 6 | ||
7 | #include <linux/kernel.h> | 7 | #include <linux/kernel.h> |
8 | #include <linux/module.h> | 8 | #include <linux/module.h> |
9 | #include <linux/slab.h> | ||
9 | #include <net/sock.h> | 10 | #include <net/sock.h> |
10 | #include <linux/workqueue.h> | 11 | #include <linux/workqueue.h> |
11 | #include <linux/connector.h> | 12 | #include <linux/connector.h> |
@@ -172,11 +173,15 @@ int dm_consult_userspace(const char *uuid, uint64_t luid, int request_type, | |||
172 | { | 173 | { |
173 | int r = 0; | 174 | int r = 0; |
174 | size_t dummy = 0; | 175 | size_t dummy = 0; |
175 | int overhead_size = | 176 | int overhead_size = sizeof(struct dm_ulog_request) + sizeof(struct cn_msg); |
176 | sizeof(struct dm_ulog_request *) + sizeof(struct cn_msg); | ||
177 | struct dm_ulog_request *tfr = prealloced_ulog_tfr; | 177 | struct dm_ulog_request *tfr = prealloced_ulog_tfr; |
178 | struct receiving_pkg pkg; | 178 | struct receiving_pkg pkg; |
179 | 179 | ||
180 | /* | ||
181 | * Given the space needed to hold the 'struct cn_msg' and | ||
182 | * 'struct dm_ulog_request' - do we have enough payload | ||
183 | * space remaining? | ||
184 | */ | ||
180 | if (data_size > (DM_ULOG_PREALLOCED_SIZE - overhead_size)) { | 185 | if (data_size > (DM_ULOG_PREALLOCED_SIZE - overhead_size)) { |
181 | DMINFO("Size of tfr exceeds preallocated size"); | 186 | DMINFO("Size of tfr exceeds preallocated size"); |
182 | return -EINVAL; | 187 | return -EINVAL; |
@@ -191,7 +196,7 @@ resend: | |||
191 | */ | 196 | */ |
192 | mutex_lock(&dm_ulog_lock); | 197 | mutex_lock(&dm_ulog_lock); |
193 | 198 | ||
194 | memset(tfr, 0, DM_ULOG_PREALLOCED_SIZE - overhead_size); | 199 | memset(tfr, 0, DM_ULOG_PREALLOCED_SIZE - sizeof(struct cn_msg)); |
195 | memcpy(tfr->uuid, uuid, DM_UUID_LEN); | 200 | memcpy(tfr->uuid, uuid, DM_UUID_LEN); |
196 | tfr->luid = luid; | 201 | tfr->luid = luid; |
197 | tfr->seq = dm_ulog_seq++; | 202 | tfr->seq = dm_ulog_seq++; |