net: dsa: add missing kfree on remove
authorNeil Armstrong <narmstrong@baylibre.com>
Tue, 6 Oct 2015 14:39:53 +0000 (15:39 +0100)
committerDavid S. Miller <davem@davemloft.net>
Wed, 7 Oct 2015 11:56:06 +0000 (04:56 -0700)
To prevent memory leakage on unbinding, add missing kfree calls.
Includes minor cosmetic change to make patch clean.

Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/dsa/dsa.c

index c59fa5d9c22c449b4bfa9f058575d44324cfd7f9..ed9d43fd1fecd3dbe1af8ee96995fd46db07b762 100644 (file)
@@ -914,8 +914,10 @@ static void dsa_remove_dst(struct dsa_switch_tree *dst)
        for (i = 0; i < dst->pd->nr_chips; i++) {
                struct dsa_switch *ds = dst->ds[i];
 
-               if (ds != NULL)
+               if (ds) {
                        dsa_switch_destroy(ds);
+                       kfree(ds);
+               }
        }
 }
 
@@ -924,6 +926,7 @@ static int dsa_remove(struct platform_device *pdev)
        struct dsa_switch_tree *dst = platform_get_drvdata(pdev);
 
        dsa_remove_dst(dst);
+       kfree(dst);
        dsa_of_remove(&pdev->dev);
 
        return 0;