Merge tag 'for-v3.8' of git://git.infradead.org/users/cbou/linux-pstore
authorLinus Torvalds <torvalds@linux-foundation.org>
Sat, 15 Dec 2012 20:51:50 +0000 (12:51 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sat, 15 Dec 2012 20:51:50 +0000 (12:51 -0800)
Pull pstore update from Anton Vorontsov:
 "Here are just a few fixups for the pstore subsystem, nothing special
  this time"

* tag 'for-v3.8' of git://git.infradead.org/users/cbou/linux-pstore:
  pstore/ftrace: Adjust for ftrace_ops->func prototype change
  pstore/ram: Fix bounds checks for mem_size, record_size, console_size and ftrace_size
  pstore/ram: Fix undefined usage of rounddown_pow_of_two(0)
  pstore/ram: Fixup section annotations

1  2 
fs/pstore/ram.c

diff --combined fs/pstore/ram.c
index 2bfa36e0ffe8d464dde8b74c37c91c46d16d49ae,dba70e53b72c427bcbee855203698f43955410cb..f883e7e74305c9935b2f26e27e92f01c7e138aa9
@@@ -132,8 -132,9 +132,8 @@@ ramoops_get_next_prz(struct persistent_
  }
  
  static ssize_t ramoops_pstore_read(u64 *id, enum pstore_type_id *type,
 -                                 struct timespec *time,
 -                                 char **buf,
 -                                 struct pstore_info *psi)
 +                                 int *count, struct timespec *time,
 +                                 char **buf, struct pstore_info *psi)
  {
        ssize_t size;
        struct ramoops_context *cxt = psi->data;
@@@ -188,7 -189,7 +188,7 @@@ static int notrace ramoops_pstore_write
                                            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) {
        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;
        return 0;
  }
  
 -static int ramoops_pstore_erase(enum pstore_type_id type, u64 id,
 -                              struct pstore_info *psi)
 +static int ramoops_pstore_erase(enum pstore_type_id type, u64 id, int count,
 +                              struct timespec time, struct pstore_info *psi)
  {
        struct ramoops_context *cxt = psi->data;
        struct persistent_ram_zone *prz;
@@@ -286,8 -292,9 +291,9 @@@ static void ramoops_free_przs(struct ra
        kfree(cxt->przs);
  }
  
- static int ramoops_init_przs(struct device *dev, struct ramoops_context *cxt,
-                             phys_addr_t *paddr, size_t dump_mem_sz)
+ static int __devinit ramoops_init_przs(struct device *dev,
+                                      struct ramoops_context *cxt,
+                                      phys_addr_t *paddr, size_t dump_mem_sz)
  {
        int err = -ENOMEM;
        int i;
        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;
@@@ -325,15 -337,20 +336,20 @@@ fail_prz
        return err;
  }
  
- static int ramoops_init_prz(struct device *dev, struct ramoops_context *cxt,
-                           struct persistent_ram_zone **prz,
-                           phys_addr_t *paddr, size_t sz, u32 sig)
+ static int __devinit ramoops_init_prz(struct device *dev,
+                                     struct ramoops_context *cxt,
+                                     struct persistent_ram_zone **prz,
+                                     phys_addr_t *paddr, size_t sz, u32 sig)
  {
        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)) {
@@@ -373,10 -390,14 +389,14 @@@ static int __devinit ramoops_probe(stru
                goto fail_out;
        }
  
-       pdata->mem_size = rounddown_pow_of_two(pdata->mem_size);
-       pdata->record_size = rounddown_pow_of_two(pdata->record_size);
-       pdata->console_size = rounddown_pow_of_two(pdata->console_size);
-       pdata->ftrace_size = rounddown_pow_of_two(pdata->ftrace_size);
+       if (!is_power_of_2(pdata->mem_size))
+               pdata->mem_size = rounddown_pow_of_two(pdata->mem_size);
+       if (!is_power_of_2(pdata->record_size))
+               pdata->record_size = rounddown_pow_of_two(pdata->record_size);
+       if (!is_power_of_2(pdata->console_size))
+               pdata->console_size = rounddown_pow_of_two(pdata->console_size);
+       if (!is_power_of_2(pdata->ftrace_size))
+               pdata->ftrace_size = rounddown_pow_of_two(pdata->ftrace_size);
  
        cxt->dump_read_cnt = 0;
        cxt->size = pdata->mem_size;