pstore: gracefully handle NULL pstore_info functions

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>
This commit is contained in:
Kees Cook 2011-11-18 13:49:00 -08:00 committed by Tony Luck
parent 3d6d8d20ec
commit 2174f6df78
2 changed files with 5 additions and 4 deletions

View File

@ -80,6 +80,7 @@ static int pstore_unlink(struct inode *dir, struct dentry *dentry)
{ {
struct pstore_private *p = dentry->d_inode->i_private; struct pstore_private *p = dentry->d_inode->i_private;
if (p->psi->erase)
p->psi->erase(p->type, p->id, p->psi); p->psi->erase(p->type, p->id, p->psi);
return simple_unlink(dir, dentry); return simple_unlink(dir, dentry);

View File

@ -207,8 +207,7 @@ void pstore_get_records(int quiet)
return; return;
mutex_lock(&psi->read_mutex); mutex_lock(&psi->read_mutex);
rc = psi->open(psi); if (psi->open && psi->open(psi))
if (rc)
goto out; goto out;
while ((size = psi->read(&id, &type, &time, &buf, psi)) > 0) { while ((size = psi->read(&id, &type, &time, &buf, psi)) > 0) {
@ -219,6 +218,7 @@ void pstore_get_records(int quiet)
if (rc && (rc != -EEXIST || !quiet)) if (rc && (rc != -EEXIST || !quiet))
failed++; failed++;
} }
if (psi->close)
psi->close(psi); psi->close(psi);
out: out:
mutex_unlock(&psi->read_mutex); mutex_unlock(&psi->read_mutex);