diff options
Diffstat (limited to 'security/keys/compat.c')
-rw-r--r-- | security/keys/compat.c | 29 |
1 files changed, 10 insertions, 19 deletions
diff --git a/security/keys/compat.c b/security/keys/compat.c index 347896548ad3..25430a3aa7f7 100644 --- a/security/keys/compat.c +++ b/security/keys/compat.c | |||
@@ -31,30 +31,21 @@ static long compat_keyctl_instantiate_key_iov( | |||
31 | key_serial_t ringid) | 31 | key_serial_t ringid) |
32 | { | 32 | { |
33 | struct iovec iovstack[UIO_FASTIOV], *iov = iovstack; | 33 | struct iovec iovstack[UIO_FASTIOV], *iov = iovstack; |
34 | struct iov_iter from; | ||
34 | long ret; | 35 | long ret; |
35 | 36 | ||
36 | if (!_payload_iov || !ioc) | 37 | if (!_payload_iov) |
37 | goto no_payload; | 38 | ioc = 0; |
38 | 39 | ||
39 | ret = compat_rw_copy_check_uvector(WRITE, _payload_iov, ioc, | 40 | ret = compat_import_iovec(WRITE, _payload_iov, ioc, |
40 | ARRAY_SIZE(iovstack), | 41 | ARRAY_SIZE(iovstack), &iov, |
41 | iovstack, &iov); | 42 | &from); |
42 | if (ret < 0) | 43 | if (ret < 0) |
43 | goto err; | 44 | return ret; |
44 | if (ret == 0) | ||
45 | goto no_payload_free; | ||
46 | |||
47 | ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid); | ||
48 | err: | ||
49 | if (iov != iovstack) | ||
50 | kfree(iov); | ||
51 | return ret; | ||
52 | 45 | ||
53 | no_payload_free: | 46 | ret = keyctl_instantiate_key_common(id, &from, ringid); |
54 | if (iov != iovstack) | 47 | kfree(iov); |
55 | kfree(iov); | 48 | return ret; |
56 | no_payload: | ||
57 | return keyctl_instantiate_key_common(id, NULL, 0, 0, ringid); | ||
58 | } | 49 | } |
59 | 50 | ||
60 | /* | 51 | /* |