staging: fsl-dpaa2/ethsw: fix memory leak of switchdev_work [Linux 5.2.1]

staging: fsl-dpaa2/ethsw: fix memory leak of switchdev_work [Linux 5.2.1]

This Linux kernel change "staging: fsl-dpaa2/ethsw: fix memory leak of switchdev_work" is included in the Linux 5.2.1 release. This change is authored by Colin Ian King <colin.king [at]> on Sat Jun 8 12:50:31 2019 +0100. The commit for this change in Linux stable tree is 6766564 (patch) which is from upstream commit 5555ebb. The same Linux upstream change may have been applied to various maintained Linux releases and you can find all Linux releases containing changes from upstream 5555ebb.

staging: fsl-dpaa2/ethsw: fix memory leak of switchdev_work

commit 5555ebbbac822b4fa28db2be15aaf98b3c21af26 upstream.

In the default event case switchdev_work is being leaked because
nothing is queued for work. Fix this by kfree'ing switchdev_work
before returning NOTIFY_DONE.

Addresses-Coverity: ("Resource leak")
Fixes: 44baaa43d7cc ("staging: fsl-dpaa2/ethsw: Add Freescale DPAA2 Ethernet Switch driver")
Signed-off-by: Colin Ian King <>
Signed-off-by: Greg Kroah-Hartman <>

There is one line of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 drivers/staging/fsl-dpaa2/ethsw/ethsw.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c
index e3c3e42..f73edaf 100644
--- a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c
+++ b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c
@@ -1086,6 +1086,7 @@ static int port_switchdev_event(struct notifier_block *unused,
+       kfree(switchdev_work);
        return NOTIFY_DONE;

Leave a Reply

Your email address will not be published. Required fields are marked *