pstore: gracefully handle NULL pstore_info functions
authorKees Cook <keescook@chromium.org>
Fri, 18 Nov 2011 21:49:00 +0000 (13:49 -0800)
committerTony Luck <tony.luck@intel.com>
Fri, 18 Nov 2011 21:49:00 +0000 (13:49 -0800)
If a pstore backend doesn't want to support various portions of the
pstore interface, it can just leave those functions NULL instead of
creating no-op stubs.

Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Tony Luck <tony.luck@intel.com>
fs/pstore/inode.c
fs/pstore/platform.c

index 379a02dc1217adf24450af7bae64279e78d85793..b3b426edb2fd7b341b8ab1940f891114e752615f 100644 (file)
@@ -80,7 +80,8 @@ static int pstore_unlink(struct inode *dir, struct dentry *dentry)
 {
        struct pstore_private *p = dentry->d_inode->i_private;
 
-       p->psi->erase(p->type, p->id, p->psi);
+       if (p->psi->erase)
+               p->psi->erase(p->type, p->id, p->psi);
 
        return simple_unlink(dir, dentry);
 }
index f146d89179bff3600dcd8d5fc83e448a4ea062b4..9ec22d3b4293f3c2d2c994927fd7102e4a20baec 100644 (file)
@@ -207,8 +207,7 @@ void pstore_get_records(int quiet)
                return;
 
        mutex_lock(&psi->read_mutex);
-       rc = psi->open(psi);
-       if (rc)
+       if (psi->open && psi->open(psi))
                goto out;
 
        while ((size = psi->read(&id, &type, &time, &buf, psi)) > 0) {
@@ -219,7 +218,8 @@ void pstore_get_records(int quiet)
                if (rc && (rc != -EEXIST || !quiet))
                        failed++;
        }
-       psi->close(psi);
+       if (psi->close)
+               psi->close(psi);
 out:
        mutex_unlock(&psi->read_mutex);