Contents of /trunk/kernel-magellan/patches-4.15/0100-4.15.1-all-fixes.patch
Parent Directory | Revision Log
Revision 3079 -
(show annotations)
(download)
Mon Feb 5 11:35:51 2018 UTC (6 years, 7 months ago) by niro
File size: 62211 byte(s)
Mon Feb 5 11:35:51 2018 UTC (6 years, 7 months ago) by niro
File size: 62211 byte(s)
-linux-4.15.1
1 | diff --git a/Makefile b/Makefile |
2 | index c8b8e902d5a4..af101b556ba0 100644 |
3 | --- a/Makefile |
4 | +++ b/Makefile |
5 | @@ -1,7 +1,7 @@ |
6 | # SPDX-License-Identifier: GPL-2.0 |
7 | VERSION = 4 |
8 | PATCHLEVEL = 15 |
9 | -SUBLEVEL = 0 |
10 | +SUBLEVEL = 1 |
11 | EXTRAVERSION = |
12 | NAME = Fearless Coyote |
13 | |
14 | diff --git a/arch/x86/crypto/aesni-intel_asm.S b/arch/x86/crypto/aesni-intel_asm.S |
15 | index 3d09e3aca18d..12e8484a8ee7 100644 |
16 | --- a/arch/x86/crypto/aesni-intel_asm.S |
17 | +++ b/arch/x86/crypto/aesni-intel_asm.S |
18 | @@ -90,30 +90,6 @@ SHIFT_MASK: .octa 0x0f0e0d0c0b0a09080706050403020100 |
19 | ALL_F: .octa 0xffffffffffffffffffffffffffffffff |
20 | .octa 0x00000000000000000000000000000000 |
21 | |
22 | -.section .rodata |
23 | -.align 16 |
24 | -.type aad_shift_arr, @object |
25 | -.size aad_shift_arr, 272 |
26 | -aad_shift_arr: |
27 | - .octa 0xffffffffffffffffffffffffffffffff |
28 | - .octa 0xffffffffffffffffffffffffffffff0C |
29 | - .octa 0xffffffffffffffffffffffffffff0D0C |
30 | - .octa 0xffffffffffffffffffffffffff0E0D0C |
31 | - .octa 0xffffffffffffffffffffffff0F0E0D0C |
32 | - .octa 0xffffffffffffffffffffff0C0B0A0908 |
33 | - .octa 0xffffffffffffffffffff0D0C0B0A0908 |
34 | - .octa 0xffffffffffffffffff0E0D0C0B0A0908 |
35 | - .octa 0xffffffffffffffff0F0E0D0C0B0A0908 |
36 | - .octa 0xffffffffffffff0C0B0A090807060504 |
37 | - .octa 0xffffffffffff0D0C0B0A090807060504 |
38 | - .octa 0xffffffffff0E0D0C0B0A090807060504 |
39 | - .octa 0xffffffff0F0E0D0C0B0A090807060504 |
40 | - .octa 0xffffff0C0B0A09080706050403020100 |
41 | - .octa 0xffff0D0C0B0A09080706050403020100 |
42 | - .octa 0xff0E0D0C0B0A09080706050403020100 |
43 | - .octa 0x0F0E0D0C0B0A09080706050403020100 |
44 | - |
45 | - |
46 | .text |
47 | |
48 | |
49 | @@ -257,6 +233,37 @@ aad_shift_arr: |
50 | pxor \TMP1, \GH # result is in TMP1 |
51 | .endm |
52 | |
53 | +# Reads DLEN bytes starting at DPTR and stores in XMMDst |
54 | +# where 0 < DLEN < 16 |
55 | +# Clobbers %rax, DLEN and XMM1 |
56 | +.macro READ_PARTIAL_BLOCK DPTR DLEN XMM1 XMMDst |
57 | + cmp $8, \DLEN |
58 | + jl _read_lt8_\@ |
59 | + mov (\DPTR), %rax |
60 | + MOVQ_R64_XMM %rax, \XMMDst |
61 | + sub $8, \DLEN |
62 | + jz _done_read_partial_block_\@ |
63 | + xor %eax, %eax |
64 | +_read_next_byte_\@: |
65 | + shl $8, %rax |
66 | + mov 7(\DPTR, \DLEN, 1), %al |
67 | + dec \DLEN |
68 | + jnz _read_next_byte_\@ |
69 | + MOVQ_R64_XMM %rax, \XMM1 |
70 | + pslldq $8, \XMM1 |
71 | + por \XMM1, \XMMDst |
72 | + jmp _done_read_partial_block_\@ |
73 | +_read_lt8_\@: |
74 | + xor %eax, %eax |
75 | +_read_next_byte_lt8_\@: |
76 | + shl $8, %rax |
77 | + mov -1(\DPTR, \DLEN, 1), %al |
78 | + dec \DLEN |
79 | + jnz _read_next_byte_lt8_\@ |
80 | + MOVQ_R64_XMM %rax, \XMMDst |
81 | +_done_read_partial_block_\@: |
82 | +.endm |
83 | + |
84 | /* |
85 | * if a = number of total plaintext bytes |
86 | * b = floor(a/16) |
87 | @@ -273,62 +280,30 @@ aad_shift_arr: |
88 | XMM2 XMM3 XMM4 XMMDst TMP6 TMP7 i i_seq operation |
89 | MOVADQ SHUF_MASK(%rip), %xmm14 |
90 | mov arg7, %r10 # %r10 = AAD |
91 | - mov arg8, %r12 # %r12 = aadLen |
92 | - mov %r12, %r11 |
93 | + mov arg8, %r11 # %r11 = aadLen |
94 | pxor %xmm\i, %xmm\i |
95 | pxor \XMM2, \XMM2 |
96 | |
97 | cmp $16, %r11 |
98 | - jl _get_AAD_rest8\num_initial_blocks\operation |
99 | + jl _get_AAD_rest\num_initial_blocks\operation |
100 | _get_AAD_blocks\num_initial_blocks\operation: |
101 | movdqu (%r10), %xmm\i |
102 | PSHUFB_XMM %xmm14, %xmm\i # byte-reflect the AAD data |
103 | pxor %xmm\i, \XMM2 |
104 | GHASH_MUL \XMM2, \TMP3, \TMP1, \TMP2, \TMP4, \TMP5, \XMM1 |
105 | add $16, %r10 |
106 | - sub $16, %r12 |
107 | sub $16, %r11 |
108 | cmp $16, %r11 |
109 | jge _get_AAD_blocks\num_initial_blocks\operation |
110 | |
111 | movdqu \XMM2, %xmm\i |
112 | + |
113 | + /* read the last <16B of AAD */ |
114 | +_get_AAD_rest\num_initial_blocks\operation: |
115 | cmp $0, %r11 |
116 | je _get_AAD_done\num_initial_blocks\operation |
117 | |
118 | - pxor %xmm\i,%xmm\i |
119 | - |
120 | - /* read the last <16B of AAD. since we have at least 4B of |
121 | - data right after the AAD (the ICV, and maybe some CT), we can |
122 | - read 4B/8B blocks safely, and then get rid of the extra stuff */ |
123 | -_get_AAD_rest8\num_initial_blocks\operation: |
124 | - cmp $4, %r11 |
125 | - jle _get_AAD_rest4\num_initial_blocks\operation |
126 | - movq (%r10), \TMP1 |
127 | - add $8, %r10 |
128 | - sub $8, %r11 |
129 | - pslldq $8, \TMP1 |
130 | - psrldq $8, %xmm\i |
131 | - pxor \TMP1, %xmm\i |
132 | - jmp _get_AAD_rest8\num_initial_blocks\operation |
133 | -_get_AAD_rest4\num_initial_blocks\operation: |
134 | - cmp $0, %r11 |
135 | - jle _get_AAD_rest0\num_initial_blocks\operation |
136 | - mov (%r10), %eax |
137 | - movq %rax, \TMP1 |
138 | - add $4, %r10 |
139 | - sub $4, %r10 |
140 | - pslldq $12, \TMP1 |
141 | - psrldq $4, %xmm\i |
142 | - pxor \TMP1, %xmm\i |
143 | -_get_AAD_rest0\num_initial_blocks\operation: |
144 | - /* finalize: shift out the extra bytes we read, and align |
145 | - left. since pslldq can only shift by an immediate, we use |
146 | - vpshufb and an array of shuffle masks */ |
147 | - movq %r12, %r11 |
148 | - salq $4, %r11 |
149 | - movdqu aad_shift_arr(%r11), \TMP1 |
150 | - PSHUFB_XMM \TMP1, %xmm\i |
151 | -_get_AAD_rest_final\num_initial_blocks\operation: |
152 | + READ_PARTIAL_BLOCK %r10, %r11, \TMP1, %xmm\i |
153 | PSHUFB_XMM %xmm14, %xmm\i # byte-reflect the AAD data |
154 | pxor \XMM2, %xmm\i |
155 | GHASH_MUL %xmm\i, \TMP3, \TMP1, \TMP2, \TMP4, \TMP5, \XMM1 |
156 | @@ -532,62 +507,30 @@ _initial_blocks_done\num_initial_blocks\operation: |
157 | XMM2 XMM3 XMM4 XMMDst TMP6 TMP7 i i_seq operation |
158 | MOVADQ SHUF_MASK(%rip), %xmm14 |
159 | mov arg7, %r10 # %r10 = AAD |
160 | - mov arg8, %r12 # %r12 = aadLen |
161 | - mov %r12, %r11 |
162 | + mov arg8, %r11 # %r11 = aadLen |
163 | pxor %xmm\i, %xmm\i |
164 | pxor \XMM2, \XMM2 |
165 | |
166 | cmp $16, %r11 |
167 | - jl _get_AAD_rest8\num_initial_blocks\operation |
168 | + jl _get_AAD_rest\num_initial_blocks\operation |
169 | _get_AAD_blocks\num_initial_blocks\operation: |
170 | movdqu (%r10), %xmm\i |
171 | PSHUFB_XMM %xmm14, %xmm\i # byte-reflect the AAD data |
172 | pxor %xmm\i, \XMM2 |
173 | GHASH_MUL \XMM2, \TMP3, \TMP1, \TMP2, \TMP4, \TMP5, \XMM1 |
174 | add $16, %r10 |
175 | - sub $16, %r12 |
176 | sub $16, %r11 |
177 | cmp $16, %r11 |
178 | jge _get_AAD_blocks\num_initial_blocks\operation |
179 | |
180 | movdqu \XMM2, %xmm\i |
181 | + |
182 | + /* read the last <16B of AAD */ |
183 | +_get_AAD_rest\num_initial_blocks\operation: |
184 | cmp $0, %r11 |
185 | je _get_AAD_done\num_initial_blocks\operation |
186 | |
187 | - pxor %xmm\i,%xmm\i |
188 | - |
189 | - /* read the last <16B of AAD. since we have at least 4B of |
190 | - data right after the AAD (the ICV, and maybe some PT), we can |
191 | - read 4B/8B blocks safely, and then get rid of the extra stuff */ |
192 | -_get_AAD_rest8\num_initial_blocks\operation: |
193 | - cmp $4, %r11 |
194 | - jle _get_AAD_rest4\num_initial_blocks\operation |
195 | - movq (%r10), \TMP1 |
196 | - add $8, %r10 |
197 | - sub $8, %r11 |
198 | - pslldq $8, \TMP1 |
199 | - psrldq $8, %xmm\i |
200 | - pxor \TMP1, %xmm\i |
201 | - jmp _get_AAD_rest8\num_initial_blocks\operation |
202 | -_get_AAD_rest4\num_initial_blocks\operation: |
203 | - cmp $0, %r11 |
204 | - jle _get_AAD_rest0\num_initial_blocks\operation |
205 | - mov (%r10), %eax |
206 | - movq %rax, \TMP1 |
207 | - add $4, %r10 |
208 | - sub $4, %r10 |
209 | - pslldq $12, \TMP1 |
210 | - psrldq $4, %xmm\i |
211 | - pxor \TMP1, %xmm\i |
212 | -_get_AAD_rest0\num_initial_blocks\operation: |
213 | - /* finalize: shift out the extra bytes we read, and align |
214 | - left. since pslldq can only shift by an immediate, we use |
215 | - vpshufb and an array of shuffle masks */ |
216 | - movq %r12, %r11 |
217 | - salq $4, %r11 |
218 | - movdqu aad_shift_arr(%r11), \TMP1 |
219 | - PSHUFB_XMM \TMP1, %xmm\i |
220 | -_get_AAD_rest_final\num_initial_blocks\operation: |
221 | + READ_PARTIAL_BLOCK %r10, %r11, \TMP1, %xmm\i |
222 | PSHUFB_XMM %xmm14, %xmm\i # byte-reflect the AAD data |
223 | pxor \XMM2, %xmm\i |
224 | GHASH_MUL %xmm\i, \TMP3, \TMP1, \TMP2, \TMP4, \TMP5, \XMM1 |
225 | @@ -1386,14 +1329,6 @@ _esb_loop_\@: |
226 | * |
227 | * AAD Format with 64-bit Extended Sequence Number |
228 | * |
229 | -* aadLen: |
230 | -* from the definition of the spec, aadLen can only be 8 or 12 bytes. |
231 | -* The code supports 16 too but for other sizes, the code will fail. |
232 | -* |
233 | -* TLen: |
234 | -* from the definition of the spec, TLen can only be 8, 12 or 16 bytes. |
235 | -* For other sizes, the code will fail. |
236 | -* |
237 | * poly = x^128 + x^127 + x^126 + x^121 + 1 |
238 | * |
239 | *****************************************************************************/ |
240 | @@ -1487,19 +1422,16 @@ _zero_cipher_left_decrypt: |
241 | PSHUFB_XMM %xmm10, %xmm0 |
242 | |
243 | ENCRYPT_SINGLE_BLOCK %xmm0, %xmm1 # E(K, Yn) |
244 | - sub $16, %r11 |
245 | - add %r13, %r11 |
246 | - movdqu (%arg3,%r11,1), %xmm1 # receive the last <16 byte block |
247 | - lea SHIFT_MASK+16(%rip), %r12 |
248 | - sub %r13, %r12 |
249 | -# adjust the shuffle mask pointer to be able to shift 16-%r13 bytes |
250 | -# (%r13 is the number of bytes in plaintext mod 16) |
251 | - movdqu (%r12), %xmm2 # get the appropriate shuffle mask |
252 | - PSHUFB_XMM %xmm2, %xmm1 # right shift 16-%r13 butes |
253 | |
254 | + lea (%arg3,%r11,1), %r10 |
255 | + mov %r13, %r12 |
256 | + READ_PARTIAL_BLOCK %r10 %r12 %xmm2 %xmm1 |
257 | + |
258 | + lea ALL_F+16(%rip), %r12 |
259 | + sub %r13, %r12 |
260 | movdqa %xmm1, %xmm2 |
261 | pxor %xmm1, %xmm0 # Ciphertext XOR E(K, Yn) |
262 | - movdqu ALL_F-SHIFT_MASK(%r12), %xmm1 |
263 | + movdqu (%r12), %xmm1 |
264 | # get the appropriate mask to mask out top 16-%r13 bytes of %xmm0 |
265 | pand %xmm1, %xmm0 # mask out top 16-%r13 bytes of %xmm0 |
266 | pand %xmm1, %xmm2 |
267 | @@ -1508,9 +1440,6 @@ _zero_cipher_left_decrypt: |
268 | |
269 | pxor %xmm2, %xmm8 |
270 | GHASH_MUL %xmm8, %xmm13, %xmm9, %xmm10, %xmm11, %xmm5, %xmm6 |
271 | - # GHASH computation for the last <16 byte block |
272 | - sub %r13, %r11 |
273 | - add $16, %r11 |
274 | |
275 | # output %r13 bytes |
276 | MOVQ_R64_XMM %xmm0, %rax |
277 | @@ -1664,14 +1593,6 @@ ENDPROC(aesni_gcm_dec) |
278 | * |
279 | * AAD Format with 64-bit Extended Sequence Number |
280 | * |
281 | -* aadLen: |
282 | -* from the definition of the spec, aadLen can only be 8 or 12 bytes. |
283 | -* The code supports 16 too but for other sizes, the code will fail. |
284 | -* |
285 | -* TLen: |
286 | -* from the definition of the spec, TLen can only be 8, 12 or 16 bytes. |
287 | -* For other sizes, the code will fail. |
288 | -* |
289 | * poly = x^128 + x^127 + x^126 + x^121 + 1 |
290 | ***************************************************************************/ |
291 | ENTRY(aesni_gcm_enc) |
292 | @@ -1764,19 +1685,16 @@ _zero_cipher_left_encrypt: |
293 | movdqa SHUF_MASK(%rip), %xmm10 |
294 | PSHUFB_XMM %xmm10, %xmm0 |
295 | |
296 | - |
297 | ENCRYPT_SINGLE_BLOCK %xmm0, %xmm1 # Encrypt(K, Yn) |
298 | - sub $16, %r11 |
299 | - add %r13, %r11 |
300 | - movdqu (%arg3,%r11,1), %xmm1 # receive the last <16 byte blocks |
301 | - lea SHIFT_MASK+16(%rip), %r12 |
302 | + |
303 | + lea (%arg3,%r11,1), %r10 |
304 | + mov %r13, %r12 |
305 | + READ_PARTIAL_BLOCK %r10 %r12 %xmm2 %xmm1 |
306 | + |
307 | + lea ALL_F+16(%rip), %r12 |
308 | sub %r13, %r12 |
309 | - # adjust the shuffle mask pointer to be able to shift 16-r13 bytes |
310 | - # (%r13 is the number of bytes in plaintext mod 16) |
311 | - movdqu (%r12), %xmm2 # get the appropriate shuffle mask |
312 | - PSHUFB_XMM %xmm2, %xmm1 # shift right 16-r13 byte |
313 | pxor %xmm1, %xmm0 # Plaintext XOR Encrypt(K, Yn) |
314 | - movdqu ALL_F-SHIFT_MASK(%r12), %xmm1 |
315 | + movdqu (%r12), %xmm1 |
316 | # get the appropriate mask to mask out top 16-r13 bytes of xmm0 |
317 | pand %xmm1, %xmm0 # mask out top 16-r13 bytes of xmm0 |
318 | movdqa SHUF_MASK(%rip), %xmm10 |
319 | @@ -1785,9 +1703,6 @@ _zero_cipher_left_encrypt: |
320 | pxor %xmm0, %xmm8 |
321 | GHASH_MUL %xmm8, %xmm13, %xmm9, %xmm10, %xmm11, %xmm5, %xmm6 |
322 | # GHASH computation for the last <16 byte block |
323 | - sub %r13, %r11 |
324 | - add $16, %r11 |
325 | - |
326 | movdqa SHUF_MASK(%rip), %xmm10 |
327 | PSHUFB_XMM %xmm10, %xmm0 |
328 | |
329 | diff --git a/arch/x86/crypto/aesni-intel_glue.c b/arch/x86/crypto/aesni-intel_glue.c |
330 | index 3bf3dcf29825..34cf1c1f8c98 100644 |
331 | --- a/arch/x86/crypto/aesni-intel_glue.c |
332 | +++ b/arch/x86/crypto/aesni-intel_glue.c |
333 | @@ -690,8 +690,8 @@ static int common_rfc4106_set_key(struct crypto_aead *aead, const u8 *key, |
334 | rfc4106_set_hash_subkey(ctx->hash_subkey, key, key_len); |
335 | } |
336 | |
337 | -static int rfc4106_set_key(struct crypto_aead *parent, const u8 *key, |
338 | - unsigned int key_len) |
339 | +static int gcmaes_wrapper_set_key(struct crypto_aead *parent, const u8 *key, |
340 | + unsigned int key_len) |
341 | { |
342 | struct cryptd_aead **ctx = crypto_aead_ctx(parent); |
343 | struct cryptd_aead *cryptd_tfm = *ctx; |
344 | @@ -716,8 +716,8 @@ static int common_rfc4106_set_authsize(struct crypto_aead *aead, |
345 | |
346 | /* This is the Integrity Check Value (aka the authentication tag length and can |
347 | * be 8, 12 or 16 bytes long. */ |
348 | -static int rfc4106_set_authsize(struct crypto_aead *parent, |
349 | - unsigned int authsize) |
350 | +static int gcmaes_wrapper_set_authsize(struct crypto_aead *parent, |
351 | + unsigned int authsize) |
352 | { |
353 | struct cryptd_aead **ctx = crypto_aead_ctx(parent); |
354 | struct cryptd_aead *cryptd_tfm = *ctx; |
355 | @@ -824,7 +824,7 @@ static int gcmaes_decrypt(struct aead_request *req, unsigned int assoclen, |
356 | if (sg_is_last(req->src) && |
357 | (!PageHighMem(sg_page(req->src)) || |
358 | req->src->offset + req->src->length <= PAGE_SIZE) && |
359 | - sg_is_last(req->dst) && |
360 | + sg_is_last(req->dst) && req->dst->length && |
361 | (!PageHighMem(sg_page(req->dst)) || |
362 | req->dst->offset + req->dst->length <= PAGE_SIZE)) { |
363 | one_entry_in_sg = 1; |
364 | @@ -929,7 +929,7 @@ static int helper_rfc4106_decrypt(struct aead_request *req) |
365 | aes_ctx); |
366 | } |
367 | |
368 | -static int rfc4106_encrypt(struct aead_request *req) |
369 | +static int gcmaes_wrapper_encrypt(struct aead_request *req) |
370 | { |
371 | struct crypto_aead *tfm = crypto_aead_reqtfm(req); |
372 | struct cryptd_aead **ctx = crypto_aead_ctx(tfm); |
373 | @@ -945,7 +945,7 @@ static int rfc4106_encrypt(struct aead_request *req) |
374 | return crypto_aead_encrypt(req); |
375 | } |
376 | |
377 | -static int rfc4106_decrypt(struct aead_request *req) |
378 | +static int gcmaes_wrapper_decrypt(struct aead_request *req) |
379 | { |
380 | struct crypto_aead *tfm = crypto_aead_reqtfm(req); |
381 | struct cryptd_aead **ctx = crypto_aead_ctx(tfm); |
382 | @@ -1117,7 +1117,7 @@ static int generic_gcmaes_decrypt(struct aead_request *req) |
383 | { |
384 | __be32 counter = cpu_to_be32(1); |
385 | struct crypto_aead *tfm = crypto_aead_reqtfm(req); |
386 | - struct aesni_rfc4106_gcm_ctx *ctx = aesni_rfc4106_gcm_ctx_get(tfm); |
387 | + struct generic_gcmaes_ctx *ctx = generic_gcmaes_ctx_get(tfm); |
388 | void *aes_ctx = &(ctx->aes_key_expanded); |
389 | u8 iv[16] __attribute__ ((__aligned__(AESNI_ALIGN))); |
390 | |
391 | @@ -1128,6 +1128,30 @@ static int generic_gcmaes_decrypt(struct aead_request *req) |
392 | aes_ctx); |
393 | } |
394 | |
395 | +static int generic_gcmaes_init(struct crypto_aead *aead) |
396 | +{ |
397 | + struct cryptd_aead *cryptd_tfm; |
398 | + struct cryptd_aead **ctx = crypto_aead_ctx(aead); |
399 | + |
400 | + cryptd_tfm = cryptd_alloc_aead("__driver-generic-gcm-aes-aesni", |
401 | + CRYPTO_ALG_INTERNAL, |
402 | + CRYPTO_ALG_INTERNAL); |
403 | + if (IS_ERR(cryptd_tfm)) |
404 | + return PTR_ERR(cryptd_tfm); |
405 | + |
406 | + *ctx = cryptd_tfm; |
407 | + crypto_aead_set_reqsize(aead, crypto_aead_reqsize(&cryptd_tfm->base)); |
408 | + |
409 | + return 0; |
410 | +} |
411 | + |
412 | +static void generic_gcmaes_exit(struct crypto_aead *aead) |
413 | +{ |
414 | + struct cryptd_aead **ctx = crypto_aead_ctx(aead); |
415 | + |
416 | + cryptd_free_aead(*ctx); |
417 | +} |
418 | + |
419 | static struct aead_alg aesni_aead_algs[] = { { |
420 | .setkey = common_rfc4106_set_key, |
421 | .setauthsize = common_rfc4106_set_authsize, |
422 | @@ -1147,10 +1171,10 @@ static struct aead_alg aesni_aead_algs[] = { { |
423 | }, { |
424 | .init = rfc4106_init, |
425 | .exit = rfc4106_exit, |
426 | - .setkey = rfc4106_set_key, |
427 | - .setauthsize = rfc4106_set_authsize, |
428 | - .encrypt = rfc4106_encrypt, |
429 | - .decrypt = rfc4106_decrypt, |
430 | + .setkey = gcmaes_wrapper_set_key, |
431 | + .setauthsize = gcmaes_wrapper_set_authsize, |
432 | + .encrypt = gcmaes_wrapper_encrypt, |
433 | + .decrypt = gcmaes_wrapper_decrypt, |
434 | .ivsize = GCM_RFC4106_IV_SIZE, |
435 | .maxauthsize = 16, |
436 | .base = { |
437 | @@ -1169,14 +1193,32 @@ static struct aead_alg aesni_aead_algs[] = { { |
438 | .decrypt = generic_gcmaes_decrypt, |
439 | .ivsize = GCM_AES_IV_SIZE, |
440 | .maxauthsize = 16, |
441 | + .base = { |
442 | + .cra_name = "__generic-gcm-aes-aesni", |
443 | + .cra_driver_name = "__driver-generic-gcm-aes-aesni", |
444 | + .cra_priority = 0, |
445 | + .cra_flags = CRYPTO_ALG_INTERNAL, |
446 | + .cra_blocksize = 1, |
447 | + .cra_ctxsize = sizeof(struct generic_gcmaes_ctx), |
448 | + .cra_alignmask = AESNI_ALIGN - 1, |
449 | + .cra_module = THIS_MODULE, |
450 | + }, |
451 | +}, { |
452 | + .init = generic_gcmaes_init, |
453 | + .exit = generic_gcmaes_exit, |
454 | + .setkey = gcmaes_wrapper_set_key, |
455 | + .setauthsize = gcmaes_wrapper_set_authsize, |
456 | + .encrypt = gcmaes_wrapper_encrypt, |
457 | + .decrypt = gcmaes_wrapper_decrypt, |
458 | + .ivsize = GCM_AES_IV_SIZE, |
459 | + .maxauthsize = 16, |
460 | .base = { |
461 | .cra_name = "gcm(aes)", |
462 | .cra_driver_name = "generic-gcm-aesni", |
463 | .cra_priority = 400, |
464 | .cra_flags = CRYPTO_ALG_ASYNC, |
465 | .cra_blocksize = 1, |
466 | - .cra_ctxsize = sizeof(struct generic_gcmaes_ctx), |
467 | - .cra_alignmask = AESNI_ALIGN - 1, |
468 | + .cra_ctxsize = sizeof(struct cryptd_aead *), |
469 | .cra_module = THIS_MODULE, |
470 | }, |
471 | } }; |
472 | diff --git a/crypto/Kconfig b/crypto/Kconfig |
473 | index f7911963bb79..9327fbfccf5a 100644 |
474 | --- a/crypto/Kconfig |
475 | +++ b/crypto/Kconfig |
476 | @@ -130,7 +130,7 @@ config CRYPTO_DH |
477 | |
478 | config CRYPTO_ECDH |
479 | tristate "ECDH algorithm" |
480 | - select CRYTPO_KPP |
481 | + select CRYPTO_KPP |
482 | select CRYPTO_RNG_DEFAULT |
483 | help |
484 | Generic implementation of the ECDH algorithm |
485 | diff --git a/crypto/af_alg.c b/crypto/af_alg.c |
486 | index 35d4dcea381f..5231f421ad00 100644 |
487 | --- a/crypto/af_alg.c |
488 | +++ b/crypto/af_alg.c |
489 | @@ -150,7 +150,7 @@ EXPORT_SYMBOL_GPL(af_alg_release_parent); |
490 | |
491 | static int alg_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) |
492 | { |
493 | - const u32 forbidden = CRYPTO_ALG_INTERNAL; |
494 | + const u32 allowed = CRYPTO_ALG_KERN_DRIVER_ONLY; |
495 | struct sock *sk = sock->sk; |
496 | struct alg_sock *ask = alg_sk(sk); |
497 | struct sockaddr_alg *sa = (void *)uaddr; |
498 | @@ -158,6 +158,10 @@ static int alg_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) |
499 | void *private; |
500 | int err; |
501 | |
502 | + /* If caller uses non-allowed flag, return error. */ |
503 | + if ((sa->salg_feat & ~allowed) || (sa->salg_mask & ~allowed)) |
504 | + return -EINVAL; |
505 | + |
506 | if (sock->state == SS_CONNECTED) |
507 | return -EINVAL; |
508 | |
509 | @@ -176,9 +180,7 @@ static int alg_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) |
510 | if (IS_ERR(type)) |
511 | return PTR_ERR(type); |
512 | |
513 | - private = type->bind(sa->salg_name, |
514 | - sa->salg_feat & ~forbidden, |
515 | - sa->salg_mask & ~forbidden); |
516 | + private = type->bind(sa->salg_name, sa->salg_feat, sa->salg_mask); |
517 | if (IS_ERR(private)) { |
518 | module_put(type->owner); |
519 | return PTR_ERR(private); |
520 | diff --git a/crypto/sha3_generic.c b/crypto/sha3_generic.c |
521 | index 7e8ed96236ce..a68be626017c 100644 |
522 | --- a/crypto/sha3_generic.c |
523 | +++ b/crypto/sha3_generic.c |
524 | @@ -18,6 +18,7 @@ |
525 | #include <linux/types.h> |
526 | #include <crypto/sha3.h> |
527 | #include <asm/byteorder.h> |
528 | +#include <asm/unaligned.h> |
529 | |
530 | #define KECCAK_ROUNDS 24 |
531 | |
532 | @@ -149,7 +150,7 @@ static int sha3_update(struct shash_desc *desc, const u8 *data, |
533 | unsigned int i; |
534 | |
535 | for (i = 0; i < sctx->rsizw; i++) |
536 | - sctx->st[i] ^= ((u64 *) src)[i]; |
537 | + sctx->st[i] ^= get_unaligned_le64(src + 8 * i); |
538 | keccakf(sctx->st); |
539 | |
540 | done += sctx->rsiz; |
541 | @@ -174,7 +175,7 @@ static int sha3_final(struct shash_desc *desc, u8 *out) |
542 | sctx->buf[sctx->rsiz - 1] |= 0x80; |
543 | |
544 | for (i = 0; i < sctx->rsizw; i++) |
545 | - sctx->st[i] ^= ((u64 *) sctx->buf)[i]; |
546 | + sctx->st[i] ^= get_unaligned_le64(sctx->buf + 8 * i); |
547 | |
548 | keccakf(sctx->st); |
549 | |
550 | diff --git a/drivers/android/binder.c b/drivers/android/binder.c |
551 | index a7ecfde66b7b..ec0917fb7cca 100644 |
552 | --- a/drivers/android/binder.c |
553 | +++ b/drivers/android/binder.c |
554 | @@ -4302,6 +4302,18 @@ static int binder_thread_release(struct binder_proc *proc, |
555 | if (t) |
556 | spin_lock(&t->lock); |
557 | } |
558 | + |
559 | + /* |
560 | + * If this thread used poll, make sure we remove the waitqueue |
561 | + * from any epoll data structures holding it with POLLFREE. |
562 | + * waitqueue_active() is safe to use here because we're holding |
563 | + * the inner lock. |
564 | + */ |
565 | + if ((thread->looper & BINDER_LOOPER_STATE_POLL) && |
566 | + waitqueue_active(&thread->wait)) { |
567 | + wake_up_poll(&thread->wait, POLLHUP | POLLFREE); |
568 | + } |
569 | + |
570 | binder_inner_proc_unlock(thread->proc); |
571 | |
572 | if (send_reply) |
573 | diff --git a/drivers/android/binder_alloc.c b/drivers/android/binder_alloc.c |
574 | index 6f6f745605af..bef8c65af8fc 100644 |
575 | --- a/drivers/android/binder_alloc.c |
576 | +++ b/drivers/android/binder_alloc.c |
577 | @@ -666,7 +666,7 @@ int binder_alloc_mmap_handler(struct binder_alloc *alloc, |
578 | goto err_already_mapped; |
579 | } |
580 | |
581 | - area = get_vm_area(vma->vm_end - vma->vm_start, VM_IOREMAP); |
582 | + area = get_vm_area(vma->vm_end - vma->vm_start, VM_ALLOC); |
583 | if (area == NULL) { |
584 | ret = -ENOMEM; |
585 | failure_string = "get_vm_area"; |
586 | diff --git a/drivers/bluetooth/hci_serdev.c b/drivers/bluetooth/hci_serdev.c |
587 | index 71664b22ec9d..e0e6461b9200 100644 |
588 | --- a/drivers/bluetooth/hci_serdev.c |
589 | +++ b/drivers/bluetooth/hci_serdev.c |
590 | @@ -303,6 +303,7 @@ int hci_uart_register_device(struct hci_uart *hu, |
591 | hci_set_drvdata(hdev, hu); |
592 | |
593 | INIT_WORK(&hu->write_work, hci_uart_write_work); |
594 | + percpu_init_rwsem(&hu->proto_lock); |
595 | |
596 | /* Only when vendor specific setup callback is provided, consider |
597 | * the manufacturer information valid. This avoids filling in the |
598 | diff --git a/drivers/crypto/inside-secure/safexcel_hash.c b/drivers/crypto/inside-secure/safexcel_hash.c |
599 | index 0c5a5820b06e..da9d040bccc2 100644 |
600 | --- a/drivers/crypto/inside-secure/safexcel_hash.c |
601 | +++ b/drivers/crypto/inside-secure/safexcel_hash.c |
602 | @@ -34,6 +34,8 @@ struct safexcel_ahash_req { |
603 | bool hmac; |
604 | bool needs_inv; |
605 | |
606 | + int nents; |
607 | + |
608 | u8 state_sz; /* expected sate size, only set once */ |
609 | u32 state[SHA256_DIGEST_SIZE / sizeof(u32)] __aligned(sizeof(u32)); |
610 | |
611 | @@ -152,8 +154,10 @@ static int safexcel_handle_req_result(struct safexcel_crypto_priv *priv, int rin |
612 | memcpy(areq->result, sreq->state, |
613 | crypto_ahash_digestsize(ahash)); |
614 | |
615 | - dma_unmap_sg(priv->dev, areq->src, |
616 | - sg_nents_for_len(areq->src, areq->nbytes), DMA_TO_DEVICE); |
617 | + if (sreq->nents) { |
618 | + dma_unmap_sg(priv->dev, areq->src, sreq->nents, DMA_TO_DEVICE); |
619 | + sreq->nents = 0; |
620 | + } |
621 | |
622 | safexcel_free_context(priv, async, sreq->state_sz); |
623 | |
624 | @@ -178,7 +182,7 @@ static int safexcel_ahash_send_req(struct crypto_async_request *async, int ring, |
625 | struct safexcel_command_desc *cdesc, *first_cdesc = NULL; |
626 | struct safexcel_result_desc *rdesc; |
627 | struct scatterlist *sg; |
628 | - int i, nents, queued, len, cache_len, extra, n_cdesc = 0, ret = 0; |
629 | + int i, queued, len, cache_len, extra, n_cdesc = 0, ret = 0; |
630 | |
631 | queued = len = req->len - req->processed; |
632 | if (queued < crypto_ahash_blocksize(ahash)) |
633 | @@ -186,17 +190,31 @@ static int safexcel_ahash_send_req(struct crypto_async_request *async, int ring, |
634 | else |
635 | cache_len = queued - areq->nbytes; |
636 | |
637 | - /* |
638 | - * If this is not the last request and the queued data does not fit |
639 | - * into full blocks, cache it for the next send() call. |
640 | - */ |
641 | - extra = queued & (crypto_ahash_blocksize(ahash) - 1); |
642 | - if (!req->last_req && extra) { |
643 | - sg_pcopy_to_buffer(areq->src, sg_nents(areq->src), |
644 | - req->cache_next, extra, areq->nbytes - extra); |
645 | - |
646 | - queued -= extra; |
647 | - len -= extra; |
648 | + if (!req->last_req) { |
649 | + /* If this is not the last request and the queued data does not |
650 | + * fit into full blocks, cache it for the next send() call. |
651 | + */ |
652 | + extra = queued & (crypto_ahash_blocksize(ahash) - 1); |
653 | + if (!extra) |
654 | + /* If this is not the last request and the queued data |
655 | + * is a multiple of a block, cache the last one for now. |
656 | + */ |
657 | + extra = queued - crypto_ahash_blocksize(ahash); |
658 | + |
659 | + if (extra) { |
660 | + sg_pcopy_to_buffer(areq->src, sg_nents(areq->src), |
661 | + req->cache_next, extra, |
662 | + areq->nbytes - extra); |
663 | + |
664 | + queued -= extra; |
665 | + len -= extra; |
666 | + |
667 | + if (!queued) { |
668 | + *commands = 0; |
669 | + *results = 0; |
670 | + return 0; |
671 | + } |
672 | + } |
673 | } |
674 | |
675 | spin_lock_bh(&priv->ring[ring].egress_lock); |
676 | @@ -234,15 +252,15 @@ static int safexcel_ahash_send_req(struct crypto_async_request *async, int ring, |
677 | } |
678 | |
679 | /* Now handle the current ahash request buffer(s) */ |
680 | - nents = dma_map_sg(priv->dev, areq->src, |
681 | - sg_nents_for_len(areq->src, areq->nbytes), |
682 | - DMA_TO_DEVICE); |
683 | - if (!nents) { |
684 | + req->nents = dma_map_sg(priv->dev, areq->src, |
685 | + sg_nents_for_len(areq->src, areq->nbytes), |
686 | + DMA_TO_DEVICE); |
687 | + if (!req->nents) { |
688 | ret = -ENOMEM; |
689 | goto cdesc_rollback; |
690 | } |
691 | |
692 | - for_each_sg(areq->src, sg, nents, i) { |
693 | + for_each_sg(areq->src, sg, req->nents, i) { |
694 | int sglen = sg_dma_len(sg); |
695 | |
696 | /* Do not overflow the request */ |
697 | diff --git a/drivers/firmware/efi/Kconfig b/drivers/firmware/efi/Kconfig |
698 | index 2b4c39fdfa91..86210f75d233 100644 |
699 | --- a/drivers/firmware/efi/Kconfig |
700 | +++ b/drivers/firmware/efi/Kconfig |
701 | @@ -159,7 +159,10 @@ config RESET_ATTACK_MITIGATION |
702 | using the TCG Platform Reset Attack Mitigation specification. This |
703 | protects against an attacker forcibly rebooting the system while it |
704 | still contains secrets in RAM, booting another OS and extracting the |
705 | - secrets. |
706 | + secrets. This should only be enabled when userland is configured to |
707 | + clear the MemoryOverwriteRequest flag on clean shutdown after secrets |
708 | + have been evicted, since otherwise it will trigger even on clean |
709 | + reboots. |
710 | |
711 | endmenu |
712 | |
713 | diff --git a/drivers/gpio/gpio-ath79.c b/drivers/gpio/gpio-ath79.c |
714 | index 5fad89dfab7e..3ae7c1876bf4 100644 |
715 | --- a/drivers/gpio/gpio-ath79.c |
716 | +++ b/drivers/gpio/gpio-ath79.c |
717 | @@ -324,3 +324,6 @@ static struct platform_driver ath79_gpio_driver = { |
718 | }; |
719 | |
720 | module_platform_driver(ath79_gpio_driver); |
721 | + |
722 | +MODULE_DESCRIPTION("Atheros AR71XX/AR724X/AR913X GPIO API support"); |
723 | +MODULE_LICENSE("GPL v2"); |
724 | diff --git a/drivers/gpio/gpio-iop.c b/drivers/gpio/gpio-iop.c |
725 | index 98c7ff2a76e7..8d62db447ec1 100644 |
726 | --- a/drivers/gpio/gpio-iop.c |
727 | +++ b/drivers/gpio/gpio-iop.c |
728 | @@ -58,3 +58,7 @@ static int __init iop3xx_gpio_init(void) |
729 | return platform_driver_register(&iop3xx_gpio_driver); |
730 | } |
731 | arch_initcall(iop3xx_gpio_init); |
732 | + |
733 | +MODULE_DESCRIPTION("GPIO handling for Intel IOP3xx processors"); |
734 | +MODULE_AUTHOR("Lennert Buytenhek <buytenh@wantstofly.org>"); |
735 | +MODULE_LICENSE("GPL"); |
736 | diff --git a/drivers/gpio/gpio-stmpe.c b/drivers/gpio/gpio-stmpe.c |
737 | index e6e5cca624a7..a365feff2377 100644 |
738 | --- a/drivers/gpio/gpio-stmpe.c |
739 | +++ b/drivers/gpio/gpio-stmpe.c |
740 | @@ -190,6 +190,16 @@ static void stmpe_gpio_irq_sync_unlock(struct irq_data *d) |
741 | }; |
742 | int i, j; |
743 | |
744 | + /* |
745 | + * STMPE1600: to be able to get IRQ from pins, |
746 | + * a read must be done on GPMR register, or a write in |
747 | + * GPSR or GPCR registers |
748 | + */ |
749 | + if (stmpe->partnum == STMPE1600) { |
750 | + stmpe_reg_read(stmpe, stmpe->regs[STMPE_IDX_GPMR_LSB]); |
751 | + stmpe_reg_read(stmpe, stmpe->regs[STMPE_IDX_GPMR_CSB]); |
752 | + } |
753 | + |
754 | for (i = 0; i < CACHE_NR_REGS; i++) { |
755 | /* STMPE801 and STMPE1600 don't have RE and FE registers */ |
756 | if ((stmpe->partnum == STMPE801 || |
757 | @@ -227,21 +237,11 @@ static void stmpe_gpio_irq_unmask(struct irq_data *d) |
758 | { |
759 | struct gpio_chip *gc = irq_data_get_irq_chip_data(d); |
760 | struct stmpe_gpio *stmpe_gpio = gpiochip_get_data(gc); |
761 | - struct stmpe *stmpe = stmpe_gpio->stmpe; |
762 | int offset = d->hwirq; |
763 | int regoffset = offset / 8; |
764 | int mask = BIT(offset % 8); |
765 | |
766 | stmpe_gpio->regs[REG_IE][regoffset] |= mask; |
767 | - |
768 | - /* |
769 | - * STMPE1600 workaround: to be able to get IRQ from pins, |
770 | - * a read must be done on GPMR register, or a write in |
771 | - * GPSR or GPCR registers |
772 | - */ |
773 | - if (stmpe->partnum == STMPE1600) |
774 | - stmpe_reg_read(stmpe, |
775 | - stmpe->regs[STMPE_IDX_GPMR_LSB + regoffset]); |
776 | } |
777 | |
778 | static void stmpe_dbg_show_one(struct seq_file *s, |
779 | diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c |
780 | index 14532d9576e4..f6efcf94f6ad 100644 |
781 | --- a/drivers/gpio/gpiolib.c |
782 | +++ b/drivers/gpio/gpiolib.c |
783 | @@ -732,6 +732,9 @@ static irqreturn_t lineevent_irq_thread(int irq, void *p) |
784 | struct gpioevent_data ge; |
785 | int ret, level; |
786 | |
787 | + /* Do not leak kernel stack to userspace */ |
788 | + memset(&ge, 0, sizeof(ge)); |
789 | + |
790 | ge.timestamp = ktime_get_real_ns(); |
791 | level = gpiod_get_value_cansleep(le->desc); |
792 | |
793 | diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c |
794 | index ee71ad9b6cc1..76531796bd3c 100644 |
795 | --- a/drivers/hid/wacom_sys.c |
796 | +++ b/drivers/hid/wacom_sys.c |
797 | @@ -2347,23 +2347,23 @@ static void wacom_remote_destroy_one(struct wacom *wacom, unsigned int index) |
798 | int i; |
799 | unsigned long flags; |
800 | |
801 | - spin_lock_irqsave(&remote->remote_lock, flags); |
802 | - remote->remotes[index].registered = false; |
803 | - spin_unlock_irqrestore(&remote->remote_lock, flags); |
804 | + for (i = 0; i < WACOM_MAX_REMOTES; i++) { |
805 | + if (remote->remotes[i].serial == serial) { |
806 | |
807 | - if (remote->remotes[index].battery.battery) |
808 | - devres_release_group(&wacom->hdev->dev, |
809 | - &remote->remotes[index].battery.bat_desc); |
810 | + spin_lock_irqsave(&remote->remote_lock, flags); |
811 | + remote->remotes[i].registered = false; |
812 | + spin_unlock_irqrestore(&remote->remote_lock, flags); |
813 | |
814 | - if (remote->remotes[index].group.name) |
815 | - devres_release_group(&wacom->hdev->dev, |
816 | - &remote->remotes[index]); |
817 | + if (remote->remotes[i].battery.battery) |
818 | + devres_release_group(&wacom->hdev->dev, |
819 | + &remote->remotes[i].battery.bat_desc); |
820 | + |
821 | + if (remote->remotes[i].group.name) |
822 | + devres_release_group(&wacom->hdev->dev, |
823 | + &remote->remotes[i]); |
824 | |
825 | - for (i = 0; i < WACOM_MAX_REMOTES; i++) { |
826 | - if (remote->remotes[i].serial == serial) { |
827 | remote->remotes[i].serial = 0; |
828 | remote->remotes[i].group.name = NULL; |
829 | - remote->remotes[i].registered = false; |
830 | remote->remotes[i].battery.battery = NULL; |
831 | wacom->led.groups[i].select = WACOM_STATUS_UNKNOWN; |
832 | } |
833 | diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c |
834 | index 16af6886e828..7dbff253c05c 100644 |
835 | --- a/drivers/hid/wacom_wac.c |
836 | +++ b/drivers/hid/wacom_wac.c |
837 | @@ -1924,7 +1924,6 @@ static void wacom_wac_pad_event(struct hid_device *hdev, struct hid_field *field |
838 | struct wacom_features *features = &wacom_wac->features; |
839 | unsigned equivalent_usage = wacom_equivalent_usage(usage->hid); |
840 | int i; |
841 | - bool is_touch_on = value; |
842 | bool do_report = false; |
843 | |
844 | /* |
845 | @@ -1969,16 +1968,17 @@ static void wacom_wac_pad_event(struct hid_device *hdev, struct hid_field *field |
846 | break; |
847 | |
848 | case WACOM_HID_WD_MUTE_DEVICE: |
849 | - if (wacom_wac->shared->touch_input && value) { |
850 | - wacom_wac->shared->is_touch_on = !wacom_wac->shared->is_touch_on; |
851 | - is_touch_on = wacom_wac->shared->is_touch_on; |
852 | - } |
853 | - |
854 | - /* fall through*/ |
855 | case WACOM_HID_WD_TOUCHONOFF: |
856 | if (wacom_wac->shared->touch_input) { |
857 | + bool *is_touch_on = &wacom_wac->shared->is_touch_on; |
858 | + |
859 | + if (equivalent_usage == WACOM_HID_WD_MUTE_DEVICE && value) |
860 | + *is_touch_on = !(*is_touch_on); |
861 | + else if (equivalent_usage == WACOM_HID_WD_TOUCHONOFF) |
862 | + *is_touch_on = value; |
863 | + |
864 | input_report_switch(wacom_wac->shared->touch_input, |
865 | - SW_MUTE_DEVICE, !is_touch_on); |
866 | + SW_MUTE_DEVICE, !(*is_touch_on)); |
867 | input_sync(wacom_wac->shared->touch_input); |
868 | } |
869 | break; |
870 | diff --git a/drivers/iio/adc/stm32-adc.c b/drivers/iio/adc/stm32-adc.c |
871 | index c9d96f935dba..cecf1e5b244c 100644 |
872 | --- a/drivers/iio/adc/stm32-adc.c |
873 | +++ b/drivers/iio/adc/stm32-adc.c |
874 | @@ -1315,6 +1315,7 @@ static int stm32_adc_set_watermark(struct iio_dev *indio_dev, unsigned int val) |
875 | { |
876 | struct stm32_adc *adc = iio_priv(indio_dev); |
877 | unsigned int watermark = STM32_DMA_BUFFER_SIZE / 2; |
878 | + unsigned int rx_buf_sz = STM32_DMA_BUFFER_SIZE; |
879 | |
880 | /* |
881 | * dma cyclic transfers are used, buffer is split into two periods. |
882 | @@ -1323,7 +1324,7 @@ static int stm32_adc_set_watermark(struct iio_dev *indio_dev, unsigned int val) |
883 | * - one buffer (period) driver can push with iio_trigger_poll(). |
884 | */ |
885 | watermark = min(watermark, val * (unsigned)(sizeof(u16))); |
886 | - adc->rx_buf_sz = watermark * 2; |
887 | + adc->rx_buf_sz = min(rx_buf_sz, watermark * 2 * adc->num_conv); |
888 | |
889 | return 0; |
890 | } |
891 | diff --git a/drivers/iio/chemical/ccs811.c b/drivers/iio/chemical/ccs811.c |
892 | index 97bce8345c6a..fbe2431f5b81 100644 |
893 | --- a/drivers/iio/chemical/ccs811.c |
894 | +++ b/drivers/iio/chemical/ccs811.c |
895 | @@ -96,7 +96,6 @@ static const struct iio_chan_spec ccs811_channels[] = { |
896 | .channel2 = IIO_MOD_CO2, |
897 | .modified = 1, |
898 | .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | |
899 | - BIT(IIO_CHAN_INFO_OFFSET) | |
900 | BIT(IIO_CHAN_INFO_SCALE), |
901 | .scan_index = 0, |
902 | .scan_type = { |
903 | @@ -255,24 +254,18 @@ static int ccs811_read_raw(struct iio_dev *indio_dev, |
904 | switch (chan->channel2) { |
905 | case IIO_MOD_CO2: |
906 | *val = 0; |
907 | - *val2 = 12834; |
908 | + *val2 = 100; |
909 | return IIO_VAL_INT_PLUS_MICRO; |
910 | case IIO_MOD_VOC: |
911 | *val = 0; |
912 | - *val2 = 84246; |
913 | - return IIO_VAL_INT_PLUS_MICRO; |
914 | + *val2 = 100; |
915 | + return IIO_VAL_INT_PLUS_NANO; |
916 | default: |
917 | return -EINVAL; |
918 | } |
919 | default: |
920 | return -EINVAL; |
921 | } |
922 | - case IIO_CHAN_INFO_OFFSET: |
923 | - if (!(chan->type == IIO_CONCENTRATION && |
924 | - chan->channel2 == IIO_MOD_CO2)) |
925 | - return -EINVAL; |
926 | - *val = -400; |
927 | - return IIO_VAL_INT; |
928 | default: |
929 | return -EINVAL; |
930 | } |
931 | diff --git a/drivers/input/rmi4/rmi_driver.c b/drivers/input/rmi4/rmi_driver.c |
932 | index 141ea228aac6..f5954981e9ee 100644 |
933 | --- a/drivers/input/rmi4/rmi_driver.c |
934 | +++ b/drivers/input/rmi4/rmi_driver.c |
935 | @@ -41,6 +41,13 @@ void rmi_free_function_list(struct rmi_device *rmi_dev) |
936 | |
937 | rmi_dbg(RMI_DEBUG_CORE, &rmi_dev->dev, "Freeing function list\n"); |
938 | |
939 | + /* Doing it in the reverse order so F01 will be removed last */ |
940 | + list_for_each_entry_safe_reverse(fn, tmp, |
941 | + &data->function_list, node) { |
942 | + list_del(&fn->node); |
943 | + rmi_unregister_function(fn); |
944 | + } |
945 | + |
946 | devm_kfree(&rmi_dev->dev, data->irq_memory); |
947 | data->irq_memory = NULL; |
948 | data->irq_status = NULL; |
949 | @@ -50,13 +57,6 @@ void rmi_free_function_list(struct rmi_device *rmi_dev) |
950 | |
951 | data->f01_container = NULL; |
952 | data->f34_container = NULL; |
953 | - |
954 | - /* Doing it in the reverse order so F01 will be removed last */ |
955 | - list_for_each_entry_safe_reverse(fn, tmp, |
956 | - &data->function_list, node) { |
957 | - list_del(&fn->node); |
958 | - rmi_unregister_function(fn); |
959 | - } |
960 | } |
961 | |
962 | static int reset_one_function(struct rmi_function *fn) |
963 | diff --git a/drivers/input/rmi4/rmi_f03.c b/drivers/input/rmi4/rmi_f03.c |
964 | index ad71a5e768dc..7ccbb370a9a8 100644 |
965 | --- a/drivers/input/rmi4/rmi_f03.c |
966 | +++ b/drivers/input/rmi4/rmi_f03.c |
967 | @@ -32,6 +32,7 @@ struct f03_data { |
968 | struct rmi_function *fn; |
969 | |
970 | struct serio *serio; |
971 | + bool serio_registered; |
972 | |
973 | unsigned int overwrite_buttons; |
974 | |
975 | @@ -138,6 +139,37 @@ static int rmi_f03_initialize(struct f03_data *f03) |
976 | return 0; |
977 | } |
978 | |
979 | +static int rmi_f03_pt_open(struct serio *serio) |
980 | +{ |
981 | + struct f03_data *f03 = serio->port_data; |
982 | + struct rmi_function *fn = f03->fn; |
983 | + const u8 ob_len = f03->rx_queue_length * RMI_F03_OB_SIZE; |
984 | + const u16 data_addr = fn->fd.data_base_addr + RMI_F03_OB_OFFSET; |
985 | + u8 obs[RMI_F03_QUEUE_LENGTH * RMI_F03_OB_SIZE]; |
986 | + int error; |
987 | + |
988 | + /* |
989 | + * Consume any pending data. Some devices like to spam with |
990 | + * 0xaa 0x00 announcements which may confuse us as we try to |
991 | + * probe the device. |
992 | + */ |
993 | + error = rmi_read_block(fn->rmi_dev, data_addr, &obs, ob_len); |
994 | + if (!error) |
995 | + rmi_dbg(RMI_DEBUG_FN, &fn->dev, |
996 | + "%s: Consumed %*ph (%d) from PS2 guest\n", |
997 | + __func__, ob_len, obs, ob_len); |
998 | + |
999 | + return fn->rmi_dev->driver->set_irq_bits(fn->rmi_dev, fn->irq_mask); |
1000 | +} |
1001 | + |
1002 | +static void rmi_f03_pt_close(struct serio *serio) |
1003 | +{ |
1004 | + struct f03_data *f03 = serio->port_data; |
1005 | + struct rmi_function *fn = f03->fn; |
1006 | + |
1007 | + fn->rmi_dev->driver->clear_irq_bits(fn->rmi_dev, fn->irq_mask); |
1008 | +} |
1009 | + |
1010 | static int rmi_f03_register_pt(struct f03_data *f03) |
1011 | { |
1012 | struct serio *serio; |
1013 | @@ -148,6 +180,8 @@ static int rmi_f03_register_pt(struct f03_data *f03) |
1014 | |
1015 | serio->id.type = SERIO_PS_PSTHRU; |
1016 | serio->write = rmi_f03_pt_write; |
1017 | + serio->open = rmi_f03_pt_open; |
1018 | + serio->close = rmi_f03_pt_close; |
1019 | serio->port_data = f03; |
1020 | |
1021 | strlcpy(serio->name, "Synaptics RMI4 PS/2 pass-through", |
1022 | @@ -184,17 +218,27 @@ static int rmi_f03_probe(struct rmi_function *fn) |
1023 | f03->device_count); |
1024 | |
1025 | dev_set_drvdata(dev, f03); |
1026 | - |
1027 | - error = rmi_f03_register_pt(f03); |
1028 | - if (error) |
1029 | - return error; |
1030 | - |
1031 | return 0; |
1032 | } |
1033 | |
1034 | static int rmi_f03_config(struct rmi_function *fn) |
1035 | { |
1036 | - fn->rmi_dev->driver->set_irq_bits(fn->rmi_dev, fn->irq_mask); |
1037 | + struct f03_data *f03 = dev_get_drvdata(&fn->dev); |
1038 | + int error; |
1039 | + |
1040 | + if (!f03->serio_registered) { |
1041 | + error = rmi_f03_register_pt(f03); |
1042 | + if (error) |
1043 | + return error; |
1044 | + |
1045 | + f03->serio_registered = true; |
1046 | + } else { |
1047 | + /* |
1048 | + * We must be re-configuring the sensor, just enable |
1049 | + * interrupts for this function. |
1050 | + */ |
1051 | + fn->rmi_dev->driver->set_irq_bits(fn->rmi_dev, fn->irq_mask); |
1052 | + } |
1053 | |
1054 | return 0; |
1055 | } |
1056 | @@ -204,7 +248,7 @@ static int rmi_f03_attention(struct rmi_function *fn, unsigned long *irq_bits) |
1057 | struct rmi_device *rmi_dev = fn->rmi_dev; |
1058 | struct rmi_driver_data *drvdata = dev_get_drvdata(&rmi_dev->dev); |
1059 | struct f03_data *f03 = dev_get_drvdata(&fn->dev); |
1060 | - u16 data_addr = fn->fd.data_base_addr; |
1061 | + const u16 data_addr = fn->fd.data_base_addr + RMI_F03_OB_OFFSET; |
1062 | const u8 ob_len = f03->rx_queue_length * RMI_F03_OB_SIZE; |
1063 | u8 obs[RMI_F03_QUEUE_LENGTH * RMI_F03_OB_SIZE]; |
1064 | u8 ob_status; |
1065 | @@ -226,8 +270,7 @@ static int rmi_f03_attention(struct rmi_function *fn, unsigned long *irq_bits) |
1066 | drvdata->attn_data.size -= ob_len; |
1067 | } else { |
1068 | /* Grab all of the data registers, and check them for data */ |
1069 | - error = rmi_read_block(fn->rmi_dev, data_addr + RMI_F03_OB_OFFSET, |
1070 | - &obs, ob_len); |
1071 | + error = rmi_read_block(fn->rmi_dev, data_addr, &obs, ob_len); |
1072 | if (error) { |
1073 | dev_err(&fn->dev, |
1074 | "%s: Failed to read F03 output buffers: %d\n", |
1075 | @@ -266,7 +309,8 @@ static void rmi_f03_remove(struct rmi_function *fn) |
1076 | { |
1077 | struct f03_data *f03 = dev_get_drvdata(&fn->dev); |
1078 | |
1079 | - serio_unregister_port(f03->serio); |
1080 | + if (f03->serio_registered) |
1081 | + serio_unregister_port(f03->serio); |
1082 | } |
1083 | |
1084 | struct rmi_function_handler rmi_f03_handler = { |
1085 | diff --git a/drivers/misc/mei/pci-me.c b/drivers/misc/mei/pci-me.c |
1086 | index f4f17552c9b8..4a0ccda4d04b 100644 |
1087 | --- a/drivers/misc/mei/pci-me.c |
1088 | +++ b/drivers/misc/mei/pci-me.c |
1089 | @@ -238,8 +238,11 @@ static int mei_me_probe(struct pci_dev *pdev, const struct pci_device_id *ent) |
1090 | */ |
1091 | mei_me_set_pm_domain(dev); |
1092 | |
1093 | - if (mei_pg_is_enabled(dev)) |
1094 | + if (mei_pg_is_enabled(dev)) { |
1095 | pm_runtime_put_noidle(&pdev->dev); |
1096 | + if (hw->d0i3_supported) |
1097 | + pm_runtime_allow(&pdev->dev); |
1098 | + } |
1099 | |
1100 | dev_dbg(&pdev->dev, "initialization successful.\n"); |
1101 | |
1102 | diff --git a/drivers/mtd/nand/denali_pci.c b/drivers/mtd/nand/denali_pci.c |
1103 | index 57fb7ae31412..49cb3e1f8bd0 100644 |
1104 | --- a/drivers/mtd/nand/denali_pci.c |
1105 | +++ b/drivers/mtd/nand/denali_pci.c |
1106 | @@ -125,3 +125,7 @@ static struct pci_driver denali_pci_driver = { |
1107 | .remove = denali_pci_remove, |
1108 | }; |
1109 | module_pci_driver(denali_pci_driver); |
1110 | + |
1111 | +MODULE_DESCRIPTION("PCI driver for Denali NAND controller"); |
1112 | +MODULE_AUTHOR("Intel Corporation and its suppliers"); |
1113 | +MODULE_LICENSE("GPL v2"); |
1114 | diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c |
1115 | index c208753ff5b7..c69a5b3ae8c8 100644 |
1116 | --- a/drivers/net/ethernet/intel/igb/igb_main.c |
1117 | +++ b/drivers/net/ethernet/intel/igb/igb_main.c |
1118 | @@ -3676,7 +3676,7 @@ static int __igb_close(struct net_device *netdev, bool suspending) |
1119 | |
1120 | int igb_close(struct net_device *netdev) |
1121 | { |
1122 | - if (netif_device_present(netdev)) |
1123 | + if (netif_device_present(netdev) || netdev->dismantle) |
1124 | return __igb_close(netdev, false); |
1125 | return 0; |
1126 | } |
1127 | diff --git a/drivers/power/reset/zx-reboot.c b/drivers/power/reset/zx-reboot.c |
1128 | index 7549c7f74a3c..c03e96e6a041 100644 |
1129 | --- a/drivers/power/reset/zx-reboot.c |
1130 | +++ b/drivers/power/reset/zx-reboot.c |
1131 | @@ -82,3 +82,7 @@ static struct platform_driver zx_reboot_driver = { |
1132 | }, |
1133 | }; |
1134 | module_platform_driver(zx_reboot_driver); |
1135 | + |
1136 | +MODULE_DESCRIPTION("ZTE SoCs reset driver"); |
1137 | +MODULE_AUTHOR("Jun Nie <jun.nie@linaro.org>"); |
1138 | +MODULE_LICENSE("GPL v2"); |
1139 | diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c |
1140 | index af3e4d3f9735..7173ae53c526 100644 |
1141 | --- a/drivers/scsi/aacraid/aachba.c |
1142 | +++ b/drivers/scsi/aacraid/aachba.c |
1143 | @@ -913,8 +913,15 @@ static void setinqstr(struct aac_dev *dev, void *data, int tindex) |
1144 | memset(str, ' ', sizeof(*str)); |
1145 | |
1146 | if (sup_adap_info->adapter_type_text[0]) { |
1147 | - char *cp = sup_adap_info->adapter_type_text; |
1148 | int c; |
1149 | + char *cp; |
1150 | + char *cname = kmemdup(sup_adap_info->adapter_type_text, |
1151 | + sizeof(sup_adap_info->adapter_type_text), |
1152 | + GFP_ATOMIC); |
1153 | + if (!cname) |
1154 | + return; |
1155 | + |
1156 | + cp = cname; |
1157 | if ((cp[0] == 'A') && (cp[1] == 'O') && (cp[2] == 'C')) |
1158 | inqstrcpy("SMC", str->vid); |
1159 | else { |
1160 | @@ -923,7 +930,7 @@ static void setinqstr(struct aac_dev *dev, void *data, int tindex) |
1161 | ++cp; |
1162 | c = *cp; |
1163 | *cp = '\0'; |
1164 | - inqstrcpy(sup_adap_info->adapter_type_text, str->vid); |
1165 | + inqstrcpy(cname, str->vid); |
1166 | *cp = c; |
1167 | while (*cp && *cp != ' ') |
1168 | ++cp; |
1169 | @@ -937,8 +944,8 @@ static void setinqstr(struct aac_dev *dev, void *data, int tindex) |
1170 | cp[sizeof(str->pid)] = '\0'; |
1171 | } |
1172 | inqstrcpy (cp, str->pid); |
1173 | - if (c) |
1174 | - cp[sizeof(str->pid)] = c; |
1175 | + |
1176 | + kfree(cname); |
1177 | } else { |
1178 | struct aac_driver_ident *mp = aac_get_driver_ident(dev->cardtype); |
1179 | |
1180 | diff --git a/drivers/scsi/aacraid/commsup.c b/drivers/scsi/aacraid/commsup.c |
1181 | index 80a8cb26cdea..d9b20dada109 100644 |
1182 | --- a/drivers/scsi/aacraid/commsup.c |
1183 | +++ b/drivers/scsi/aacraid/commsup.c |
1184 | @@ -1643,14 +1643,7 @@ static int _aac_reset_adapter(struct aac_dev *aac, int forced, u8 reset_type) |
1185 | out: |
1186 | aac->in_reset = 0; |
1187 | scsi_unblock_requests(host); |
1188 | - /* |
1189 | - * Issue bus rescan to catch any configuration that might have |
1190 | - * occurred |
1191 | - */ |
1192 | - if (!retval) { |
1193 | - dev_info(&aac->pdev->dev, "Issuing bus rescan\n"); |
1194 | - scsi_scan_host(host); |
1195 | - } |
1196 | + |
1197 | if (jafo) { |
1198 | spin_lock_irq(host->host_lock); |
1199 | } |
1200 | diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c |
1201 | index 3b3d1d050cac..40fc7a590e81 100644 |
1202 | --- a/drivers/scsi/storvsc_drv.c |
1203 | +++ b/drivers/scsi/storvsc_drv.c |
1204 | @@ -1834,8 +1834,10 @@ static int storvsc_probe(struct hv_device *device, |
1205 | fc_host_node_name(host) = stor_device->node_name; |
1206 | fc_host_port_name(host) = stor_device->port_name; |
1207 | stor_device->rport = fc_remote_port_add(host, 0, &ids); |
1208 | - if (!stor_device->rport) |
1209 | + if (!stor_device->rport) { |
1210 | + ret = -ENOMEM; |
1211 | goto err_out4; |
1212 | + } |
1213 | } |
1214 | #endif |
1215 | return 0; |
1216 | diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c |
1217 | index 79ddefe4180d..40390d31a93b 100644 |
1218 | --- a/drivers/spi/spi-imx.c |
1219 | +++ b/drivers/spi/spi-imx.c |
1220 | @@ -1668,12 +1668,23 @@ static int spi_imx_remove(struct platform_device *pdev) |
1221 | { |
1222 | struct spi_master *master = platform_get_drvdata(pdev); |
1223 | struct spi_imx_data *spi_imx = spi_master_get_devdata(master); |
1224 | + int ret; |
1225 | |
1226 | spi_bitbang_stop(&spi_imx->bitbang); |
1227 | |
1228 | + ret = clk_enable(spi_imx->clk_per); |
1229 | + if (ret) |
1230 | + return ret; |
1231 | + |
1232 | + ret = clk_enable(spi_imx->clk_ipg); |
1233 | + if (ret) { |
1234 | + clk_disable(spi_imx->clk_per); |
1235 | + return ret; |
1236 | + } |
1237 | + |
1238 | writel(0, spi_imx->base + MXC_CSPICTRL); |
1239 | - clk_unprepare(spi_imx->clk_ipg); |
1240 | - clk_unprepare(spi_imx->clk_per); |
1241 | + clk_disable_unprepare(spi_imx->clk_ipg); |
1242 | + clk_disable_unprepare(spi_imx->clk_per); |
1243 | spi_imx_sdma_exit(spi_imx); |
1244 | spi_master_put(master); |
1245 | |
1246 | diff --git a/drivers/staging/ccree/ssi_cipher.c b/drivers/staging/ccree/ssi_cipher.c |
1247 | index ee85cbf7c9ae..980ff42128b4 100644 |
1248 | --- a/drivers/staging/ccree/ssi_cipher.c |
1249 | +++ b/drivers/staging/ccree/ssi_cipher.c |
1250 | @@ -908,6 +908,7 @@ static int ssi_ablkcipher_decrypt(struct ablkcipher_request *req) |
1251 | scatterwalk_map_and_copy(req_ctx->backup_info, req->src, |
1252 | (req->nbytes - ivsize), ivsize, 0); |
1253 | req_ctx->is_giv = false; |
1254 | + req_ctx->backup_info = NULL; |
1255 | |
1256 | return ssi_blkcipher_process(tfm, req_ctx, req->dst, req->src, req->nbytes, req->info, ivsize, (void *)req, DRV_CRYPTO_DIRECTION_DECRYPT); |
1257 | } |
1258 | diff --git a/drivers/staging/ccree/ssi_driver.c b/drivers/staging/ccree/ssi_driver.c |
1259 | index 1a3c481fa92a..ce16c3440319 100644 |
1260 | --- a/drivers/staging/ccree/ssi_driver.c |
1261 | +++ b/drivers/staging/ccree/ssi_driver.c |
1262 | @@ -117,7 +117,7 @@ static irqreturn_t cc_isr(int irq, void *dev_id) |
1263 | irr &= ~SSI_COMP_IRQ_MASK; |
1264 | complete_request(drvdata); |
1265 | } |
1266 | -#ifdef CC_SUPPORT_FIPS |
1267 | +#ifdef CONFIG_CRYPTO_FIPS |
1268 | /* TEE FIPS interrupt */ |
1269 | if (likely((irr & SSI_GPR0_IRQ_MASK) != 0)) { |
1270 | /* Mask interrupt - will be unmasked in Deferred service handler */ |
1271 | diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c |
1272 | index 8024843521ab..7b256d716251 100644 |
1273 | --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c |
1274 | +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c |
1275 | @@ -826,14 +826,15 @@ struct kib_conn *kiblnd_create_conn(struct kib_peer *peer, struct rdma_cm_id *cm |
1276 | return conn; |
1277 | |
1278 | failed_2: |
1279 | - kiblnd_destroy_conn(conn, true); |
1280 | + kiblnd_destroy_conn(conn); |
1281 | + LIBCFS_FREE(conn, sizeof(*conn)); |
1282 | failed_1: |
1283 | LIBCFS_FREE(init_qp_attr, sizeof(*init_qp_attr)); |
1284 | failed_0: |
1285 | return NULL; |
1286 | } |
1287 | |
1288 | -void kiblnd_destroy_conn(struct kib_conn *conn, bool free_conn) |
1289 | +void kiblnd_destroy_conn(struct kib_conn *conn) |
1290 | { |
1291 | struct rdma_cm_id *cmid = conn->ibc_cmid; |
1292 | struct kib_peer *peer = conn->ibc_peer; |
1293 | @@ -896,8 +897,6 @@ void kiblnd_destroy_conn(struct kib_conn *conn, bool free_conn) |
1294 | rdma_destroy_id(cmid); |
1295 | atomic_dec(&net->ibn_nconns); |
1296 | } |
1297 | - |
1298 | - LIBCFS_FREE(conn, sizeof(*conn)); |
1299 | } |
1300 | |
1301 | int kiblnd_close_peer_conns_locked(struct kib_peer *peer, int why) |
1302 | diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h |
1303 | index 171eced213f8..b18911d09e9a 100644 |
1304 | --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h |
1305 | +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h |
1306 | @@ -1016,7 +1016,7 @@ int kiblnd_close_peer_conns_locked(struct kib_peer *peer, int why); |
1307 | struct kib_conn *kiblnd_create_conn(struct kib_peer *peer, |
1308 | struct rdma_cm_id *cmid, |
1309 | int state, int version); |
1310 | -void kiblnd_destroy_conn(struct kib_conn *conn, bool free_conn); |
1311 | +void kiblnd_destroy_conn(struct kib_conn *conn); |
1312 | void kiblnd_close_conn(struct kib_conn *conn, int error); |
1313 | void kiblnd_close_conn_locked(struct kib_conn *conn, int error); |
1314 | |
1315 | diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c |
1316 | index 40e3af5d8b04..2f25642ea1a6 100644 |
1317 | --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c |
1318 | +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c |
1319 | @@ -3314,11 +3314,13 @@ kiblnd_connd(void *arg) |
1320 | spin_unlock_irqrestore(lock, flags); |
1321 | dropped_lock = 1; |
1322 | |
1323 | - kiblnd_destroy_conn(conn, !peer); |
1324 | + kiblnd_destroy_conn(conn); |
1325 | |
1326 | spin_lock_irqsave(lock, flags); |
1327 | - if (!peer) |
1328 | + if (!peer) { |
1329 | + kfree(conn); |
1330 | continue; |
1331 | + } |
1332 | |
1333 | conn->ibc_peer = peer; |
1334 | if (peer->ibp_reconnected < KIB_RECONN_HIGH_RACE) |
1335 | diff --git a/drivers/tty/serial/8250/8250_dw.c b/drivers/tty/serial/8250/8250_dw.c |
1336 | index 5bb0c42c88dd..7070203e3157 100644 |
1337 | --- a/drivers/tty/serial/8250/8250_dw.c |
1338 | +++ b/drivers/tty/serial/8250/8250_dw.c |
1339 | @@ -252,31 +252,25 @@ static void dw8250_set_termios(struct uart_port *p, struct ktermios *termios, |
1340 | struct ktermios *old) |
1341 | { |
1342 | unsigned int baud = tty_termios_baud_rate(termios); |
1343 | - unsigned int target_rate, min_rate, max_rate; |
1344 | struct dw8250_data *d = p->private_data; |
1345 | long rate; |
1346 | - int i, ret; |
1347 | + int ret; |
1348 | |
1349 | if (IS_ERR(d->clk) || !old) |
1350 | goto out; |
1351 | |
1352 | - /* Find a clk rate within +/-1.6% of an integer multiple of baudx16 */ |
1353 | - target_rate = baud * 16; |
1354 | - min_rate = target_rate - (target_rate >> 6); |
1355 | - max_rate = target_rate + (target_rate >> 6); |
1356 | - |
1357 | - for (i = 1; i <= UART_DIV_MAX; i++) { |
1358 | - rate = clk_round_rate(d->clk, i * target_rate); |
1359 | - if (rate >= i * min_rate && rate <= i * max_rate) |
1360 | - break; |
1361 | - } |
1362 | - if (i <= UART_DIV_MAX) { |
1363 | - clk_disable_unprepare(d->clk); |
1364 | + clk_disable_unprepare(d->clk); |
1365 | + rate = clk_round_rate(d->clk, baud * 16); |
1366 | + if (rate < 0) |
1367 | + ret = rate; |
1368 | + else if (rate == 0) |
1369 | + ret = -ENOENT; |
1370 | + else |
1371 | ret = clk_set_rate(d->clk, rate); |
1372 | - clk_prepare_enable(d->clk); |
1373 | - if (!ret) |
1374 | - p->uartclk = rate; |
1375 | - } |
1376 | + clk_prepare_enable(d->clk); |
1377 | + |
1378 | + if (!ret) |
1379 | + p->uartclk = rate; |
1380 | |
1381 | out: |
1382 | p->status &= ~UPSTAT_AUTOCTS; |
1383 | diff --git a/drivers/tty/serial/8250/8250_of.c b/drivers/tty/serial/8250/8250_of.c |
1384 | index 1e67a7e4a5fd..160b8906d9b9 100644 |
1385 | --- a/drivers/tty/serial/8250/8250_of.c |
1386 | +++ b/drivers/tty/serial/8250/8250_of.c |
1387 | @@ -136,8 +136,11 @@ static int of_platform_serial_setup(struct platform_device *ofdev, |
1388 | } |
1389 | |
1390 | info->rst = devm_reset_control_get_optional_shared(&ofdev->dev, NULL); |
1391 | - if (IS_ERR(info->rst)) |
1392 | + if (IS_ERR(info->rst)) { |
1393 | + ret = PTR_ERR(info->rst); |
1394 | goto err_dispose; |
1395 | + } |
1396 | + |
1397 | ret = reset_control_deassert(info->rst); |
1398 | if (ret) |
1399 | goto err_dispose; |
1400 | diff --git a/drivers/tty/serial/8250/8250_uniphier.c b/drivers/tty/serial/8250/8250_uniphier.c |
1401 | index 45ef506293ae..28d88ccf5a0c 100644 |
1402 | --- a/drivers/tty/serial/8250/8250_uniphier.c |
1403 | +++ b/drivers/tty/serial/8250/8250_uniphier.c |
1404 | @@ -250,12 +250,13 @@ static int uniphier_uart_probe(struct platform_device *pdev) |
1405 | up.dl_read = uniphier_serial_dl_read; |
1406 | up.dl_write = uniphier_serial_dl_write; |
1407 | |
1408 | - priv->line = serial8250_register_8250_port(&up); |
1409 | - if (priv->line < 0) { |
1410 | + ret = serial8250_register_8250_port(&up); |
1411 | + if (ret < 0) { |
1412 | dev_err(dev, "failed to register 8250 port\n"); |
1413 | clk_disable_unprepare(priv->clk); |
1414 | return ret; |
1415 | } |
1416 | + priv->line = ret; |
1417 | |
1418 | platform_set_drvdata(pdev, priv); |
1419 | |
1420 | diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c |
1421 | index e4b3d9123a03..e9145ed0d6e7 100644 |
1422 | --- a/drivers/tty/serial/imx.c |
1423 | +++ b/drivers/tty/serial/imx.c |
1424 | @@ -2238,12 +2238,14 @@ static void serial_imx_enable_wakeup(struct imx_port *sport, bool on) |
1425 | val &= ~UCR3_AWAKEN; |
1426 | writel(val, sport->port.membase + UCR3); |
1427 | |
1428 | - val = readl(sport->port.membase + UCR1); |
1429 | - if (on) |
1430 | - val |= UCR1_RTSDEN; |
1431 | - else |
1432 | - val &= ~UCR1_RTSDEN; |
1433 | - writel(val, sport->port.membase + UCR1); |
1434 | + if (sport->have_rtscts) { |
1435 | + val = readl(sport->port.membase + UCR1); |
1436 | + if (on) |
1437 | + val |= UCR1_RTSDEN; |
1438 | + else |
1439 | + val &= ~UCR1_RTSDEN; |
1440 | + writel(val, sport->port.membase + UCR1); |
1441 | + } |
1442 | } |
1443 | |
1444 | static int imx_serial_port_suspend_noirq(struct device *dev) |
1445 | diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c |
1446 | index dc60aeea87d8..4b506f2d3522 100644 |
1447 | --- a/drivers/tty/tty_io.c |
1448 | +++ b/drivers/tty/tty_io.c |
1449 | @@ -1323,6 +1323,9 @@ struct tty_struct *tty_init_dev(struct tty_driver *driver, int idx) |
1450 | "%s: %s driver does not set tty->port. This will crash the kernel later. Fix the driver!\n", |
1451 | __func__, tty->driver->name); |
1452 | |
1453 | + retval = tty_ldisc_lock(tty, 5 * HZ); |
1454 | + if (retval) |
1455 | + goto err_release_lock; |
1456 | tty->port->itty = tty; |
1457 | |
1458 | /* |
1459 | @@ -1333,6 +1336,7 @@ struct tty_struct *tty_init_dev(struct tty_driver *driver, int idx) |
1460 | retval = tty_ldisc_setup(tty, tty->link); |
1461 | if (retval) |
1462 | goto err_release_tty; |
1463 | + tty_ldisc_unlock(tty); |
1464 | /* Return the tty locked so that it cannot vanish under the caller */ |
1465 | return tty; |
1466 | |
1467 | @@ -1345,9 +1349,11 @@ struct tty_struct *tty_init_dev(struct tty_driver *driver, int idx) |
1468 | |
1469 | /* call the tty release_tty routine to clean out this slot */ |
1470 | err_release_tty: |
1471 | - tty_unlock(tty); |
1472 | + tty_ldisc_unlock(tty); |
1473 | tty_info_ratelimited(tty, "ldisc open failed (%d), clearing slot %d\n", |
1474 | retval, idx); |
1475 | +err_release_lock: |
1476 | + tty_unlock(tty); |
1477 | release_tty(tty, idx); |
1478 | return ERR_PTR(retval); |
1479 | } |
1480 | diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c |
1481 | index 24ec5c7e6b20..4e7946c0484b 100644 |
1482 | --- a/drivers/tty/tty_ldisc.c |
1483 | +++ b/drivers/tty/tty_ldisc.c |
1484 | @@ -337,7 +337,7 @@ static inline void __tty_ldisc_unlock(struct tty_struct *tty) |
1485 | ldsem_up_write(&tty->ldisc_sem); |
1486 | } |
1487 | |
1488 | -static int tty_ldisc_lock(struct tty_struct *tty, unsigned long timeout) |
1489 | +int tty_ldisc_lock(struct tty_struct *tty, unsigned long timeout) |
1490 | { |
1491 | int ret; |
1492 | |
1493 | @@ -348,7 +348,7 @@ static int tty_ldisc_lock(struct tty_struct *tty, unsigned long timeout) |
1494 | return 0; |
1495 | } |
1496 | |
1497 | -static void tty_ldisc_unlock(struct tty_struct *tty) |
1498 | +void tty_ldisc_unlock(struct tty_struct *tty) |
1499 | { |
1500 | clear_bit(TTY_LDISC_HALTED, &tty->flags); |
1501 | __tty_ldisc_unlock(tty); |
1502 | diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c |
1503 | index 8e0636c963a7..18bbe3fedb8b 100644 |
1504 | --- a/drivers/usb/class/cdc-acm.c |
1505 | +++ b/drivers/usb/class/cdc-acm.c |
1506 | @@ -425,7 +425,7 @@ static int acm_submit_read_urb(struct acm *acm, int index, gfp_t mem_flags) |
1507 | |
1508 | res = usb_submit_urb(acm->read_urbs[index], mem_flags); |
1509 | if (res) { |
1510 | - if (res != -EPERM) { |
1511 | + if (res != -EPERM && res != -ENODEV) { |
1512 | dev_err(&acm->data->dev, |
1513 | "urb %d failed submission with %d\n", |
1514 | index, res); |
1515 | @@ -1752,6 +1752,9 @@ static const struct usb_device_id acm_ids[] = { |
1516 | { USB_DEVICE(0x0ace, 0x1611), /* ZyDAS 56K USB MODEM - new version */ |
1517 | .driver_info = SINGLE_RX_URB, /* firmware bug */ |
1518 | }, |
1519 | + { USB_DEVICE(0x11ca, 0x0201), /* VeriFone Mx870 Gadget Serial */ |
1520 | + .driver_info = SINGLE_RX_URB, |
1521 | + }, |
1522 | { USB_DEVICE(0x22b8, 0x7000), /* Motorola Q Phone */ |
1523 | .driver_info = NO_UNION_NORMAL, /* has no union descriptor */ |
1524 | }, |
1525 | diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c |
1526 | index b6cf5ab5a0a1..f9bd351637cd 100644 |
1527 | --- a/drivers/usb/gadget/function/f_fs.c |
1528 | +++ b/drivers/usb/gadget/function/f_fs.c |
1529 | @@ -3700,7 +3700,8 @@ static void ffs_closed(struct ffs_data *ffs) |
1530 | ci = opts->func_inst.group.cg_item.ci_parent->ci_parent; |
1531 | ffs_dev_unlock(); |
1532 | |
1533 | - unregister_gadget_item(ci); |
1534 | + if (test_bit(FFS_FL_BOUND, &ffs->flags)) |
1535 | + unregister_gadget_item(ci); |
1536 | return; |
1537 | done: |
1538 | ffs_dev_unlock(); |
1539 | diff --git a/drivers/usb/gadget/udc/core.c b/drivers/usb/gadget/udc/core.c |
1540 | index 1b3efb14aec7..ac0541529499 100644 |
1541 | --- a/drivers/usb/gadget/udc/core.c |
1542 | +++ b/drivers/usb/gadget/udc/core.c |
1543 | @@ -912,7 +912,7 @@ int usb_gadget_ep_match_desc(struct usb_gadget *gadget, |
1544 | return 0; |
1545 | |
1546 | /* "high bandwidth" works only at high speed */ |
1547 | - if (!gadget_is_dualspeed(gadget) && usb_endpoint_maxp(desc) & (3<<11)) |
1548 | + if (!gadget_is_dualspeed(gadget) && usb_endpoint_maxp_mult(desc) > 1) |
1549 | return 0; |
1550 | |
1551 | switch (type) { |
1552 | diff --git a/drivers/usb/serial/Kconfig b/drivers/usb/serial/Kconfig |
1553 | index a8d5f2e4878d..c66b93664d54 100644 |
1554 | --- a/drivers/usb/serial/Kconfig |
1555 | +++ b/drivers/usb/serial/Kconfig |
1556 | @@ -63,6 +63,7 @@ config USB_SERIAL_SIMPLE |
1557 | - Google USB serial devices |
1558 | - HP4x calculators |
1559 | - a number of Motorola phones |
1560 | + - Motorola Tetra devices |
1561 | - Novatel Wireless GPS receivers |
1562 | - Siemens USB/MPI adapter. |
1563 | - ViVOtech ViVOpay USB device. |
1564 | diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c |
1565 | index 219265ce3711..17283f4b4779 100644 |
1566 | --- a/drivers/usb/serial/io_edgeport.c |
1567 | +++ b/drivers/usb/serial/io_edgeport.c |
1568 | @@ -2282,7 +2282,6 @@ static int write_cmd_usb(struct edgeport_port *edge_port, |
1569 | /* something went wrong */ |
1570 | dev_err(dev, "%s - usb_submit_urb(write command) failed, status = %d\n", |
1571 | __func__, status); |
1572 | - usb_kill_urb(urb); |
1573 | usb_free_urb(urb); |
1574 | atomic_dec(&CmdUrbs); |
1575 | return status; |
1576 | diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c |
1577 | index b6320e3be429..5db8ed517e0e 100644 |
1578 | --- a/drivers/usb/serial/option.c |
1579 | +++ b/drivers/usb/serial/option.c |
1580 | @@ -380,6 +380,9 @@ static void option_instat_callback(struct urb *urb); |
1581 | #define FOUR_G_SYSTEMS_PRODUCT_W14 0x9603 |
1582 | #define FOUR_G_SYSTEMS_PRODUCT_W100 0x9b01 |
1583 | |
1584 | +/* Fujisoft products */ |
1585 | +#define FUJISOFT_PRODUCT_FS040U 0x9b02 |
1586 | + |
1587 | /* iBall 3.5G connect wireless modem */ |
1588 | #define IBALL_3_5G_CONNECT 0x9605 |
1589 | |
1590 | @@ -1894,6 +1897,8 @@ static const struct usb_device_id option_ids[] = { |
1591 | { USB_DEVICE(LONGCHEER_VENDOR_ID, FOUR_G_SYSTEMS_PRODUCT_W100), |
1592 | .driver_info = (kernel_ulong_t)&four_g_w100_blacklist |
1593 | }, |
1594 | + {USB_DEVICE(LONGCHEER_VENDOR_ID, FUJISOFT_PRODUCT_FS040U), |
1595 | + .driver_info = (kernel_ulong_t)&net_intf3_blacklist}, |
1596 | { USB_DEVICE_INTERFACE_CLASS(LONGCHEER_VENDOR_ID, SPEEDUP_PRODUCT_SU9800, 0xff) }, |
1597 | { USB_DEVICE_INTERFACE_CLASS(LONGCHEER_VENDOR_ID, 0x9801, 0xff), |
1598 | .driver_info = (kernel_ulong_t)&net_intf3_blacklist }, |
1599 | diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c |
1600 | index 57ae832a49ff..46dd09da2434 100644 |
1601 | --- a/drivers/usb/serial/pl2303.c |
1602 | +++ b/drivers/usb/serial/pl2303.c |
1603 | @@ -38,6 +38,7 @@ static const struct usb_device_id id_table[] = { |
1604 | { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_RSAQ2) }, |
1605 | { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_DCU11) }, |
1606 | { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_RSAQ3) }, |
1607 | + { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_CHILITAG) }, |
1608 | { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_PHAROS) }, |
1609 | { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_ALDIGA) }, |
1610 | { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_MMX) }, |
1611 | diff --git a/drivers/usb/serial/pl2303.h b/drivers/usb/serial/pl2303.h |
1612 | index f98fd84890de..fcd72396a7b6 100644 |
1613 | --- a/drivers/usb/serial/pl2303.h |
1614 | +++ b/drivers/usb/serial/pl2303.h |
1615 | @@ -12,6 +12,7 @@ |
1616 | #define PL2303_PRODUCT_ID_DCU11 0x1234 |
1617 | #define PL2303_PRODUCT_ID_PHAROS 0xaaa0 |
1618 | #define PL2303_PRODUCT_ID_RSAQ3 0xaaa2 |
1619 | +#define PL2303_PRODUCT_ID_CHILITAG 0xaaa8 |
1620 | #define PL2303_PRODUCT_ID_ALDIGA 0x0611 |
1621 | #define PL2303_PRODUCT_ID_MMX 0x0612 |
1622 | #define PL2303_PRODUCT_ID_GPRS 0x0609 |
1623 | diff --git a/drivers/usb/serial/usb-serial-simple.c b/drivers/usb/serial/usb-serial-simple.c |
1624 | index 74172fe158df..4ef79e29cb26 100644 |
1625 | --- a/drivers/usb/serial/usb-serial-simple.c |
1626 | +++ b/drivers/usb/serial/usb-serial-simple.c |
1627 | @@ -77,6 +77,11 @@ DEVICE(vivopay, VIVOPAY_IDS); |
1628 | { USB_DEVICE(0x22b8, 0x2c64) } /* Motorola V950 phone */ |
1629 | DEVICE(moto_modem, MOTO_IDS); |
1630 | |
1631 | +/* Motorola Tetra driver */ |
1632 | +#define MOTOROLA_TETRA_IDS() \ |
1633 | + { USB_DEVICE(0x0cad, 0x9011) } /* Motorola Solutions TETRA PEI */ |
1634 | +DEVICE(motorola_tetra, MOTOROLA_TETRA_IDS); |
1635 | + |
1636 | /* Novatel Wireless GPS driver */ |
1637 | #define NOVATEL_IDS() \ |
1638 | { USB_DEVICE(0x09d7, 0x0100) } /* NovAtel FlexPack GPS */ |
1639 | @@ -107,6 +112,7 @@ static struct usb_serial_driver * const serial_drivers[] = { |
1640 | &google_device, |
1641 | &vivopay_device, |
1642 | &moto_modem_device, |
1643 | + &motorola_tetra_device, |
1644 | &novatel_gps_device, |
1645 | &hp4x_device, |
1646 | &suunto_device, |
1647 | @@ -122,6 +128,7 @@ static const struct usb_device_id id_table[] = { |
1648 | GOOGLE_IDS(), |
1649 | VIVOPAY_IDS(), |
1650 | MOTO_IDS(), |
1651 | + MOTOROLA_TETRA_IDS(), |
1652 | NOVATEL_IDS(), |
1653 | HP4X_IDS(), |
1654 | SUUNTO_IDS(), |
1655 | diff --git a/drivers/usb/storage/uas.c b/drivers/usb/storage/uas.c |
1656 | index 5d04c40ee40a..3b1b9695177a 100644 |
1657 | --- a/drivers/usb/storage/uas.c |
1658 | +++ b/drivers/usb/storage/uas.c |
1659 | @@ -1076,20 +1076,19 @@ static int uas_post_reset(struct usb_interface *intf) |
1660 | return 0; |
1661 | |
1662 | err = uas_configure_endpoints(devinfo); |
1663 | - if (err) { |
1664 | + if (err && err != ENODEV) |
1665 | shost_printk(KERN_ERR, shost, |
1666 | "%s: alloc streams error %d after reset", |
1667 | __func__, err); |
1668 | - return 1; |
1669 | - } |
1670 | |
1671 | + /* we must unblock the host in every case lest we deadlock */ |
1672 | spin_lock_irqsave(shost->host_lock, flags); |
1673 | scsi_report_bus_reset(shost, 0); |
1674 | spin_unlock_irqrestore(shost->host_lock, flags); |
1675 | |
1676 | scsi_unblock_requests(shost); |
1677 | |
1678 | - return 0; |
1679 | + return err ? 1 : 0; |
1680 | } |
1681 | |
1682 | static int uas_suspend(struct usb_interface *intf, pm_message_t message) |
1683 | diff --git a/include/linux/tty.h b/include/linux/tty.h |
1684 | index 7ac8ba208b1f..0a6c71e0ad01 100644 |
1685 | --- a/include/linux/tty.h |
1686 | +++ b/include/linux/tty.h |
1687 | @@ -405,6 +405,8 @@ extern const char *tty_name(const struct tty_struct *tty); |
1688 | extern struct tty_struct *tty_kopen(dev_t device); |
1689 | extern void tty_kclose(struct tty_struct *tty); |
1690 | extern int tty_dev_name_to_number(const char *name, dev_t *number); |
1691 | +extern int tty_ldisc_lock(struct tty_struct *tty, unsigned long timeout); |
1692 | +extern void tty_ldisc_unlock(struct tty_struct *tty); |
1693 | #else |
1694 | static inline void tty_kref_put(struct tty_struct *tty) |
1695 | { } |
1696 | diff --git a/lib/test_firmware.c b/lib/test_firmware.c |
1697 | index 64a4c76cba2b..e7008688769b 100644 |
1698 | --- a/lib/test_firmware.c |
1699 | +++ b/lib/test_firmware.c |
1700 | @@ -371,6 +371,7 @@ static ssize_t config_num_requests_store(struct device *dev, |
1701 | if (test_fw_config->reqs) { |
1702 | pr_err("Must call release_all_firmware prior to changing config\n"); |
1703 | rc = -EINVAL; |
1704 | + mutex_unlock(&test_fw_mutex); |
1705 | goto out; |
1706 | } |
1707 | mutex_unlock(&test_fw_mutex); |
1708 | diff --git a/security/integrity/ima/ima_policy.c b/security/integrity/ima/ima_policy.c |
1709 | index ee4613fa5840..f19f4841a97a 100644 |
1710 | --- a/security/integrity/ima/ima_policy.c |
1711 | +++ b/security/integrity/ima/ima_policy.c |
1712 | @@ -743,7 +743,7 @@ static int ima_parse_rule(char *rule, struct ima_rule_entry *entry) |
1713 | case Opt_fsuuid: |
1714 | ima_log_string(ab, "fsuuid", args[0].from); |
1715 | |
1716 | - if (uuid_is_null(&entry->fsuuid)) { |
1717 | + if (!uuid_is_null(&entry->fsuuid)) { |
1718 | result = -EINVAL; |
1719 | break; |
1720 | } |
1721 | diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c |
1722 | index 9aafc6c86132..1750e00c5bb4 100644 |
1723 | --- a/sound/pci/hda/patch_realtek.c |
1724 | +++ b/sound/pci/hda/patch_realtek.c |
1725 | @@ -3154,11 +3154,13 @@ static void alc256_shutup(struct hda_codec *codec) |
1726 | if (hp_pin_sense) |
1727 | msleep(85); |
1728 | |
1729 | + /* 3k pull low control for Headset jack. */ |
1730 | + /* NOTE: call this before clearing the pin, otherwise codec stalls */ |
1731 | + alc_update_coef_idx(codec, 0x46, 0, 3 << 12); |
1732 | + |
1733 | snd_hda_codec_write(codec, hp_pin, 0, |
1734 | AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0); |
1735 | |
1736 | - alc_update_coef_idx(codec, 0x46, 0, 3 << 12); /* 3k pull low control for Headset jack. */ |
1737 | - |
1738 | if (hp_pin_sense) |
1739 | msleep(100); |
1740 | |
1741 | diff --git a/tools/gpio/gpio-event-mon.c b/tools/gpio/gpio-event-mon.c |
1742 | index 1c14c2595158..4b36323ea64b 100644 |
1743 | --- a/tools/gpio/gpio-event-mon.c |
1744 | +++ b/tools/gpio/gpio-event-mon.c |
1745 | @@ -23,6 +23,7 @@ |
1746 | #include <getopt.h> |
1747 | #include <inttypes.h> |
1748 | #include <sys/ioctl.h> |
1749 | +#include <sys/types.h> |
1750 | #include <linux/gpio.h> |
1751 | |
1752 | int monitor_device(const char *device_name, |
1753 | diff --git a/tools/usb/usbip/src/usbip_bind.c b/tools/usb/usbip/src/usbip_bind.c |
1754 | index fa46141ae68b..e121cfb1746a 100644 |
1755 | --- a/tools/usb/usbip/src/usbip_bind.c |
1756 | +++ b/tools/usb/usbip/src/usbip_bind.c |
1757 | @@ -144,6 +144,7 @@ static int bind_device(char *busid) |
1758 | int rc; |
1759 | struct udev *udev; |
1760 | struct udev_device *dev; |
1761 | + const char *devpath; |
1762 | |
1763 | /* Check whether the device with this bus ID exists. */ |
1764 | udev = udev_new(); |
1765 | @@ -152,8 +153,16 @@ static int bind_device(char *busid) |
1766 | err("device with the specified bus ID does not exist"); |
1767 | return -1; |
1768 | } |
1769 | + devpath = udev_device_get_devpath(dev); |
1770 | udev_unref(udev); |
1771 | |
1772 | + /* If the device is already attached to vhci_hcd - bail out */ |
1773 | + if (strstr(devpath, USBIP_VHCI_DRV_NAME)) { |
1774 | + err("bind loop detected: device: %s is attached to %s\n", |
1775 | + devpath, USBIP_VHCI_DRV_NAME); |
1776 | + return -1; |
1777 | + } |
1778 | + |
1779 | rc = unbind_other(busid); |
1780 | if (rc == UNBIND_ST_FAILED) { |
1781 | err("could not unbind driver from device on busid %s", busid); |
1782 | diff --git a/tools/usb/usbip/src/usbip_list.c b/tools/usb/usbip/src/usbip_list.c |
1783 | index f1b38e866dd7..d65a9f444174 100644 |
1784 | --- a/tools/usb/usbip/src/usbip_list.c |
1785 | +++ b/tools/usb/usbip/src/usbip_list.c |
1786 | @@ -187,6 +187,7 @@ static int list_devices(bool parsable) |
1787 | const char *busid; |
1788 | char product_name[128]; |
1789 | int ret = -1; |
1790 | + const char *devpath; |
1791 | |
1792 | /* Create libudev context. */ |
1793 | udev = udev_new(); |
1794 | @@ -209,6 +210,14 @@ static int list_devices(bool parsable) |
1795 | path = udev_list_entry_get_name(dev_list_entry); |
1796 | dev = udev_device_new_from_syspath(udev, path); |
1797 | |
1798 | + /* Ignore devices attached to vhci_hcd */ |
1799 | + devpath = udev_device_get_devpath(dev); |
1800 | + if (strstr(devpath, USBIP_VHCI_DRV_NAME)) { |
1801 | + dbg("Skip the device %s already attached to %s\n", |
1802 | + devpath, USBIP_VHCI_DRV_NAME); |
1803 | + continue; |
1804 | + } |
1805 | + |
1806 | /* Get device information. */ |
1807 | idVendor = udev_device_get_sysattr_value(dev, "idVendor"); |
1808 | idProduct = udev_device_get_sysattr_value(dev, "idProduct"); |