diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/flex_array.c | 24 | ||||
-rw-r--r-- | lib/vsprintf.c | 2 | ||||
-rw-r--r-- | lib/xz/xz_dec_lzma2.c | 6 |
3 files changed, 22 insertions, 10 deletions
diff --git a/lib/flex_array.c b/lib/flex_array.c index c0ea40ba2082..854b57bd7d9d 100644 --- a/lib/flex_array.c +++ b/lib/flex_array.c | |||
@@ -232,10 +232,10 @@ EXPORT_SYMBOL(flex_array_clear); | |||
232 | 232 | ||
233 | /** | 233 | /** |
234 | * flex_array_prealloc - guarantee that array space exists | 234 | * flex_array_prealloc - guarantee that array space exists |
235 | * @fa: the flex array for which to preallocate parts | 235 | * @fa: the flex array for which to preallocate parts |
236 | * @start: index of first array element for which space is allocated | 236 | * @start: index of first array element for which space is allocated |
237 | * @end: index of last (inclusive) element for which space is allocated | 237 | * @nr_elements: number of elements for which space is allocated |
238 | * @flags: page allocation flags | 238 | * @flags: page allocation flags |
239 | * | 239 | * |
240 | * This will guarantee that no future calls to flex_array_put() | 240 | * This will guarantee that no future calls to flex_array_put() |
241 | * will allocate memory. It can be used if you are expecting to | 241 | * will allocate memory. It can be used if you are expecting to |
@@ -245,14 +245,24 @@ EXPORT_SYMBOL(flex_array_clear); | |||
245 | * Locking must be provided by the caller. | 245 | * Locking must be provided by the caller. |
246 | */ | 246 | */ |
247 | int flex_array_prealloc(struct flex_array *fa, unsigned int start, | 247 | int flex_array_prealloc(struct flex_array *fa, unsigned int start, |
248 | unsigned int end, gfp_t flags) | 248 | unsigned int nr_elements, gfp_t flags) |
249 | { | 249 | { |
250 | int start_part; | 250 | int start_part; |
251 | int end_part; | 251 | int end_part; |
252 | int part_nr; | 252 | int part_nr; |
253 | unsigned int end; | ||
253 | struct flex_array_part *part; | 254 | struct flex_array_part *part; |
254 | 255 | ||
255 | if (start >= fa->total_nr_elements || end >= fa->total_nr_elements) | 256 | if (!start && !nr_elements) |
257 | return 0; | ||
258 | if (start >= fa->total_nr_elements) | ||
259 | return -ENOSPC; | ||
260 | if (!nr_elements) | ||
261 | return 0; | ||
262 | |||
263 | end = start + nr_elements - 1; | ||
264 | |||
265 | if (end >= fa->total_nr_elements) | ||
256 | return -ENOSPC; | 266 | return -ENOSPC; |
257 | if (elements_fit_in_base(fa)) | 267 | if (elements_fit_in_base(fa)) |
258 | return 0; | 268 | return 0; |
@@ -343,6 +353,8 @@ int flex_array_shrink(struct flex_array *fa) | |||
343 | int part_nr; | 353 | int part_nr; |
344 | int ret = 0; | 354 | int ret = 0; |
345 | 355 | ||
356 | if (!fa->total_nr_elements) | ||
357 | return 0; | ||
346 | if (elements_fit_in_base(fa)) | 358 | if (elements_fit_in_base(fa)) |
347 | return ret; | 359 | return ret; |
348 | for (part_nr = 0; part_nr < FLEX_ARRAY_NR_BASE_PTRS; part_nr++) { | 360 | for (part_nr = 0; part_nr < FLEX_ARRAY_NR_BASE_PTRS; part_nr++) { |
diff --git a/lib/vsprintf.c b/lib/vsprintf.c index bc0ac6b333dc..dfd60192bc2e 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c | |||
@@ -797,7 +797,7 @@ char *uuid_string(char *buf, char *end, const u8 *addr, | |||
797 | return string(buf, end, uuid, spec); | 797 | return string(buf, end, uuid, spec); |
798 | } | 798 | } |
799 | 799 | ||
800 | int kptr_restrict = 1; | 800 | int kptr_restrict __read_mostly; |
801 | 801 | ||
802 | /* | 802 | /* |
803 | * Show a '%p' thing. A kernel extension is that the '%p' is followed | 803 | * Show a '%p' thing. A kernel extension is that the '%p' is followed |
diff --git a/lib/xz/xz_dec_lzma2.c b/lib/xz/xz_dec_lzma2.c index ea5fa4fe9d67..a6cdc969ea42 100644 --- a/lib/xz/xz_dec_lzma2.c +++ b/lib/xz/xz_dec_lzma2.c | |||
@@ -969,6 +969,9 @@ XZ_EXTERN enum xz_ret xz_dec_lzma2_run(struct xz_dec_lzma2 *s, | |||
969 | */ | 969 | */ |
970 | tmp = b->in[b->in_pos++]; | 970 | tmp = b->in[b->in_pos++]; |
971 | 971 | ||
972 | if (tmp == 0x00) | ||
973 | return XZ_STREAM_END; | ||
974 | |||
972 | if (tmp >= 0xE0 || tmp == 0x01) { | 975 | if (tmp >= 0xE0 || tmp == 0x01) { |
973 | s->lzma2.need_props = true; | 976 | s->lzma2.need_props = true; |
974 | s->lzma2.need_dict_reset = false; | 977 | s->lzma2.need_dict_reset = false; |
@@ -1001,9 +1004,6 @@ XZ_EXTERN enum xz_ret xz_dec_lzma2_run(struct xz_dec_lzma2 *s, | |||
1001 | lzma_reset(s); | 1004 | lzma_reset(s); |
1002 | } | 1005 | } |
1003 | } else { | 1006 | } else { |
1004 | if (tmp == 0x00) | ||
1005 | return XZ_STREAM_END; | ||
1006 | |||
1007 | if (tmp > 0x02) | 1007 | if (tmp > 0x02) |
1008 | return XZ_DATA_ERROR; | 1008 | return XZ_DATA_ERROR; |
1009 | 1009 | ||