]> granicus.if.org Git - spl/commitdiff
Add missing error handling to this case where a memory allocation fails.
authorbehlendo <behlendo@7e1ea52c-4ff2-0310-8f11-9dd32ca42a1c>
Tue, 4 Nov 2008 22:51:31 +0000 (22:51 +0000)
committerbehlendo <behlendo@7e1ea52c-4ff2-0310-8f11-9dd32ca42a1c>
Tue, 4 Nov 2008 22:51:31 +0000 (22:51 +0000)
git-svn-id: https://outreach.scidac.gov/svn/spl/trunk@170 7e1ea52c-4ff2-0310-8f11-9dd32ca42a1c

modules/spl/spl-kobj.c

index 28ff74e7cd0b4142c392a34746d903b5ded66519..e78cd9244fdb64811abf5f1f60f85b07fdf983ec 100644 (file)
@@ -40,10 +40,15 @@ kobj_open_file(const char *name)
        int rc;
        ENTRY;
 
-       if ((rc = vn_open(name, UIO_SYSSPACE, FREAD, 0644, &vp, 0, 0)))
+       file = kmalloc(sizeof(_buf_t), GFP_KERNEL);
+       if (file == NULL)
                RETURN((_buf_t *)-1UL);
 
-       file = kmalloc(sizeof(_buf_t), GFP_KERNEL);
+       if ((rc = vn_open(name, UIO_SYSSPACE, FREAD, 0644, &vp, 0, 0))) {
+               kfree(file);
+               RETURN((_buf_t *)-1UL);
+       }
+
        file->vp = vp;
 
        RETURN(file);