nfp: fix nfp_cpp_read()/nfp_cpp_write() error paths
authorJakub Kicinski <jakub.kicinski@netronome.com>
Wed, 22 Mar 2017 00:59:16 +0000 (17:59 -0700)
committerDavid S. Miller <davem@davemloft.net>
Wed, 22 Mar 2017 19:59:08 +0000 (12:59 -0700)
When acquiring an area fails we can't call function doing both
release and free.

Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/netronome/nfp/nfpcore/nfp_cppcore.c

index 2e4796b52b84912abb39ddf2beadc9f7eb2b9487..e2abba4c3a3fd84225f443d82e61454d41093819 100644 (file)
@@ -951,12 +951,14 @@ int nfp_cpp_read(struct nfp_cpp *cpp, u32 destination,
                        return -ENOMEM;
 
                err = nfp_cpp_area_acquire(area);
-               if (err)
-                       goto out;
+               if (err) {
+                       nfp_cpp_area_free(area);
+                       return err;
+               }
        }
 
        err = nfp_cpp_area_read(area, offset, kernel_vaddr, length);
-out:
+
        if (cache)
                area_cache_put(cpp, cache);
        else
@@ -993,13 +995,14 @@ int nfp_cpp_write(struct nfp_cpp *cpp, u32 destination,
                        return -ENOMEM;
 
                err = nfp_cpp_area_acquire(area);
-               if (err)
-                       goto out;
+               if (err) {
+                       nfp_cpp_area_free(area);
+                       return err;
+               }
        }
 
        err = nfp_cpp_area_write(area, offset, kernel_vaddr, length);
 
-out:
        if (cache)
                area_cache_put(cpp, cache);
        else