Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 344448
b: refs/heads/master
c: c628937
h: refs/heads/master
v: v3
  • Loading branch information
Arve Hjønnevåg authored and Anton Vorontsov committed Dec 13, 2012
1 parent a9e92ac commit 8bec94d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: b042e47491ba5f487601b5141a3f1d8582304170
refs/heads/master: c628937803c652132d21f383736375e2feee4bfb
18 changes: 16 additions & 2 deletions trunk/fs/pstore/ram.c
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ static int notrace ramoops_pstore_write_buf(enum pstore_type_id type,
struct pstore_info *psi)
{
struct ramoops_context *cxt = psi->data;
struct persistent_ram_zone *prz = cxt->przs[cxt->dump_write_cnt];
struct persistent_ram_zone *prz;
size_t hlen;

if (type == PSTORE_TYPE_CONSOLE) {
Expand Down Expand Up @@ -226,6 +226,11 @@ static int notrace ramoops_pstore_write_buf(enum pstore_type_id type,
if (part != 1)
return -ENOSPC;

if (!cxt->przs)
return -ENOSPC;

prz = cxt->przs[cxt->dump_write_cnt];

hlen = ramoops_write_kmsg_hdr(prz);
if (size + hlen > prz->buffer_size)
size = prz->buffer_size - hlen;
Expand Down Expand Up @@ -297,6 +302,11 @@ static int __devinit ramoops_init_przs(struct device *dev,
if (!cxt->record_size)
return 0;

if (*paddr + dump_mem_sz - cxt->phys_addr > cxt->size) {
dev_err(dev, "no room for dumps\n");
return -ENOMEM;
}

cxt->max_dump_cnt = dump_mem_sz / cxt->record_size;
if (!cxt->max_dump_cnt)
return -ENOMEM;
Expand Down Expand Up @@ -335,8 +345,12 @@ static int __devinit ramoops_init_prz(struct device *dev,
if (!sz)
return 0;

if (*paddr + sz > *paddr + cxt->size)
if (*paddr + sz - cxt->phys_addr > cxt->size) {
dev_err(dev, "no room for mem region (0x%zx@0x%llx) in (0x%lx@0x%llx)\n",
sz, (unsigned long long)*paddr,
cxt->size, (unsigned long long)cxt->phys_addr);
return -ENOMEM;
}

*prz = persistent_ram_new(*paddr, sz, sig, cxt->ecc_size);
if (IS_ERR(*prz)) {
Expand Down

0 comments on commit 8bec94d

Please sign in to comment.