lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220308065617.90401-1-fufuyqqqqqq@gmail.com>
Date:   Mon,  7 Mar 2022 22:56:17 -0800
From:   Yeqi Fu <fufuyqqqqqq@...il.com>
To:     Heikki Krogerus <heikki.krogerus@...ux.intel.com>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc:     linux-usb@...r.kernel.org, linux-kernel@...r.kernel.org,
        lyz_cs@....edu.cn, Yeqi Fu <fuyq@....pku.edu.cn>
Subject: [PATCH 2/2] usb: typec: fix memory leak

From: Yeqi Fu <fuyq@....pku.edu.cn>

Resource release is needed on the error handling branch
to prevent memory leak. Fix this by adding kfree to the
error handling branch.

Signed-off-by: Yeqi Fu <fuyq@....pku.edu.cn>
---
 drivers/usb/typec/class.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c
index ee0e520707dd..e210109c696d 100644
--- a/drivers/usb/typec/class.c
+++ b/drivers/usb/typec/class.c
@@ -2099,6 +2099,7 @@ struct typec_port *typec_register_port(struct device *parent,
 	port->cap = kmemdup(cap, sizeof(*cap), GFP_KERNEL);
 	if (!port->cap) {
 		put_device(&port->dev);
+		kfree(port);
 		return ERR_PTR(-ENOMEM);
 	}
 
@@ -2106,6 +2107,7 @@ struct typec_port *typec_register_port(struct device *parent,
 	if (IS_ERR(port->sw)) {
 		ret = PTR_ERR(port->sw);
 		put_device(&port->dev);
+		kfree(port);
 		return ERR_PTR(ret);
 	}
 
@@ -2113,6 +2115,7 @@ struct typec_port *typec_register_port(struct device *parent,
 	if (IS_ERR(port->mux)) {
 		ret = PTR_ERR(port->mux);
 		put_device(&port->dev);
+		kfree(port);
 		return ERR_PTR(ret);
 	}
 
@@ -2120,6 +2123,7 @@ struct typec_port *typec_register_port(struct device *parent,
 	if (ret) {
 		dev_err(parent, "failed to register port (%d)\n", ret);
 		put_device(&port->dev);
+		kfree(port);
 		return ERR_PTR(ret);
 	}
 
-- 
2.30.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ