diff options
-rw-r--r-- | fs/pstore/platform.c | 1 | ||||
-rw-r--r-- | fs/pstore/ram.c | 19 | ||||
-rw-r--r-- | fs/pstore/ram_core.c | 4 |
3 files changed, 14 insertions, 10 deletions
diff --git a/fs/pstore/platform.c b/fs/pstore/platform.c index 78c3c2097787..46d269e38706 100644 --- a/fs/pstore/platform.c +++ b/fs/pstore/platform.c | |||
@@ -497,6 +497,7 @@ void pstore_get_records(int quiet) | |||
497 | big_oops_buf_sz); | 497 | big_oops_buf_sz); |
498 | 498 | ||
499 | if (unzipped_len > 0) { | 499 | if (unzipped_len > 0) { |
500 | kfree(buf); | ||
500 | buf = big_oops_buf; | 501 | buf = big_oops_buf; |
501 | size = unzipped_len; | 502 | size = unzipped_len; |
502 | compressed = false; | 503 | compressed = false; |
diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c index fa8cef2cca3a..3b5744306ed8 100644 --- a/fs/pstore/ram.c +++ b/fs/pstore/ram.c | |||
@@ -86,6 +86,7 @@ struct ramoops_context { | |||
86 | struct persistent_ram_ecc_info ecc_info; | 86 | struct persistent_ram_ecc_info ecc_info; |
87 | unsigned int max_dump_cnt; | 87 | unsigned int max_dump_cnt; |
88 | unsigned int dump_write_cnt; | 88 | unsigned int dump_write_cnt; |
89 | /* _read_cnt need clear on ramoops_pstore_open */ | ||
89 | unsigned int dump_read_cnt; | 90 | unsigned int dump_read_cnt; |
90 | unsigned int console_read_cnt; | 91 | unsigned int console_read_cnt; |
91 | unsigned int ftrace_read_cnt; | 92 | unsigned int ftrace_read_cnt; |
@@ -101,6 +102,7 @@ static int ramoops_pstore_open(struct pstore_info *psi) | |||
101 | 102 | ||
102 | cxt->dump_read_cnt = 0; | 103 | cxt->dump_read_cnt = 0; |
103 | cxt->console_read_cnt = 0; | 104 | cxt->console_read_cnt = 0; |
105 | cxt->ftrace_read_cnt = 0; | ||
104 | return 0; | 106 | return 0; |
105 | } | 107 | } |
106 | 108 | ||
@@ -117,13 +119,15 @@ ramoops_get_next_prz(struct persistent_ram_zone *przs[], uint *c, uint max, | |||
117 | return NULL; | 119 | return NULL; |
118 | 120 | ||
119 | prz = przs[i]; | 121 | prz = przs[i]; |
122 | if (!prz) | ||
123 | return NULL; | ||
120 | 124 | ||
121 | if (update) { | 125 | /* Update old/shadowed buffer. */ |
122 | /* Update old/shadowed buffer. */ | 126 | if (update) |
123 | persistent_ram_save_old(prz); | 127 | persistent_ram_save_old(prz); |
124 | if (!persistent_ram_old_size(prz)) | 128 | |
125 | return NULL; | 129 | if (!persistent_ram_old_size(prz)) |
126 | } | 130 | return NULL; |
127 | 131 | ||
128 | *typep = type; | 132 | *typep = type; |
129 | *id = i; | 133 | *id = i; |
@@ -316,6 +320,7 @@ static void ramoops_free_przs(struct ramoops_context *cxt) | |||
316 | { | 320 | { |
317 | int i; | 321 | int i; |
318 | 322 | ||
323 | cxt->max_dump_cnt = 0; | ||
319 | if (!cxt->przs) | 324 | if (!cxt->przs) |
320 | return; | 325 | return; |
321 | 326 | ||
@@ -346,7 +351,7 @@ static int ramoops_init_przs(struct device *dev, struct ramoops_context *cxt, | |||
346 | GFP_KERNEL); | 351 | GFP_KERNEL); |
347 | if (!cxt->przs) { | 352 | if (!cxt->przs) { |
348 | dev_err(dev, "failed to initialize a prz array for dumps\n"); | 353 | dev_err(dev, "failed to initialize a prz array for dumps\n"); |
349 | return -ENOMEM; | 354 | goto fail_prz; |
350 | } | 355 | } |
351 | 356 | ||
352 | for (i = 0; i < cxt->max_dump_cnt; i++) { | 357 | for (i = 0; i < cxt->max_dump_cnt; i++) { |
@@ -428,7 +433,6 @@ static int ramoops_probe(struct platform_device *pdev) | |||
428 | if (pdata->ftrace_size && !is_power_of_2(pdata->ftrace_size)) | 433 | if (pdata->ftrace_size && !is_power_of_2(pdata->ftrace_size)) |
429 | pdata->ftrace_size = rounddown_pow_of_two(pdata->ftrace_size); | 434 | pdata->ftrace_size = rounddown_pow_of_two(pdata->ftrace_size); |
430 | 435 | ||
431 | cxt->dump_read_cnt = 0; | ||
432 | cxt->size = pdata->mem_size; | 436 | cxt->size = pdata->mem_size; |
433 | cxt->phys_addr = pdata->mem_address; | 437 | cxt->phys_addr = pdata->mem_address; |
434 | cxt->record_size = pdata->record_size; | 438 | cxt->record_size = pdata->record_size; |
@@ -505,7 +509,6 @@ fail_buf: | |||
505 | kfree(cxt->pstore.buf); | 509 | kfree(cxt->pstore.buf); |
506 | fail_clear: | 510 | fail_clear: |
507 | cxt->pstore.bufsize = 0; | 511 | cxt->pstore.bufsize = 0; |
508 | cxt->max_dump_cnt = 0; | ||
509 | fail_cnt: | 512 | fail_cnt: |
510 | kfree(cxt->fprz); | 513 | kfree(cxt->fprz); |
511 | fail_init_fprz: | 514 | fail_init_fprz: |
diff --git a/fs/pstore/ram_core.c b/fs/pstore/ram_core.c index de272d426763..ff7e3d4df5a1 100644 --- a/fs/pstore/ram_core.c +++ b/fs/pstore/ram_core.c | |||
@@ -54,7 +54,7 @@ static size_t buffer_start_add_atomic(struct persistent_ram_zone *prz, size_t a) | |||
54 | do { | 54 | do { |
55 | old = atomic_read(&prz->buffer->start); | 55 | old = atomic_read(&prz->buffer->start); |
56 | new = old + a; | 56 | new = old + a; |
57 | while (unlikely(new > prz->buffer_size)) | 57 | while (unlikely(new >= prz->buffer_size)) |
58 | new -= prz->buffer_size; | 58 | new -= prz->buffer_size; |
59 | } while (atomic_cmpxchg(&prz->buffer->start, old, new) != old); | 59 | } while (atomic_cmpxchg(&prz->buffer->start, old, new) != old); |
60 | 60 | ||
@@ -91,7 +91,7 @@ static size_t buffer_start_add_locked(struct persistent_ram_zone *prz, size_t a) | |||
91 | 91 | ||
92 | old = atomic_read(&prz->buffer->start); | 92 | old = atomic_read(&prz->buffer->start); |
93 | new = old + a; | 93 | new = old + a; |
94 | while (unlikely(new > prz->buffer_size)) | 94 | while (unlikely(new >= prz->buffer_size)) |
95 | new -= prz->buffer_size; | 95 | new -= prz->buffer_size; |
96 | atomic_set(&prz->buffer->start, new); | 96 | atomic_set(&prz->buffer->start, new); |
97 | 97 | ||