diff mbox series

[net] net: hso: fix muxed tty registration

Message ID 20210917101204.10147-1-johan@kernel.org (mailing list archive)
State Accepted
Commit e8f69b16ee776da88589b5271e3f46020efc8f6c
Delegated to: Netdev Maintainers
Headers show
Series [net] net: hso: fix muxed tty registration | expand

Checks

Context Check Description
netdev/cover_letter success Link
netdev/fixes_present success Link
netdev/patch_count success Link
netdev/tree_selection success Clearly marked for net
netdev/subject_prefix success Link
netdev/cc_maintainers fail 3 blamed authors not CCed: jgarzik@redhat.com alan@lxorguk.ukuu.org.uk gregkh@linuxfoundation.org; 9 maintainers not CCed: alan@lxorguk.ukuu.org.uk gregkh@linuxfoundation.org jgarzik@redhat.com mail@anirudhrb.com jirislaby@kernel.org dsterba@suse.com kernel@esmil.dk dan.carpenter@oracle.com mudongliangabcd@gmail.com
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 5 this patch: 5
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success Link
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 30 lines checked
netdev/build_allmodconfig_warn success Errors and warnings before: 5 this patch: 5
netdev/header_inline success Link

Commit Message

Johan Hovold Sept. 17, 2021, 10:12 a.m. UTC
If resource allocation and registration fail for a muxed tty device
(e.g. if there are no more minor numbers) the driver should not try to
deregister the never-registered (or already-deregistered) tty.

Fix up the error handling to avoid dereferencing a NULL pointer when
attempting to remove the character device.

Fixes: 72dc1c096c70 ("HSO: add option hso driver")
Cc: stable@vger.kernel.org	# 2.6.27
Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/net/usb/hso.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

Comments

patchwork-bot+netdevbpf@kernel.org Sept. 17, 2021, 10:30 a.m. UTC | #1
Hello:

This patch was applied to netdev/net.git (refs/heads/master):

On Fri, 17 Sep 2021 12:12:04 +0200 you wrote:
> If resource allocation and registration fail for a muxed tty device
> (e.g. if there are no more minor numbers) the driver should not try to
> deregister the never-registered (or already-deregistered) tty.
> 
> Fix up the error handling to avoid dereferencing a NULL pointer when
> attempting to remove the character device.
> 
> [...]

Here is the summary with links:
  - [net] net: hso: fix muxed tty registration
    https://git.kernel.org/netdev/net/c/e8f69b16ee77

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
diff mbox series

Patch

diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
index a57251ba5991..f97813a4e8d1 100644
--- a/drivers/net/usb/hso.c
+++ b/drivers/net/usb/hso.c
@@ -2719,14 +2719,14 @@  struct hso_device *hso_create_mux_serial_device(struct usb_interface *interface,
 
 	serial = kzalloc(sizeof(*serial), GFP_KERNEL);
 	if (!serial)
-		goto exit;
+		goto err_free_dev;
 
 	hso_dev->port_data.dev_serial = serial;
 	serial->parent = hso_dev;
 
 	if (hso_serial_common_create
 	    (serial, 1, CTRL_URB_RX_SIZE, CTRL_URB_TX_SIZE))
-		goto exit;
+		goto err_free_serial;
 
 	serial->tx_data_length--;
 	serial->write_data = hso_mux_serial_write_data;
@@ -2742,11 +2742,9 @@  struct hso_device *hso_create_mux_serial_device(struct usb_interface *interface,
 	/* done, return it */
 	return hso_dev;
 
-exit:
-	if (serial) {
-		tty_unregister_device(tty_drv, serial->minor);
-		kfree(serial);
-	}
+err_free_serial:
+	kfree(serial);
+err_free_dev:
 	kfree(hso_dev);
 	return NULL;