summaryrefslogtreecommitdiffstats
path: root/drivers/usb/core
diff options
context:
space:
mode:
authorBhuvanesh Surachari <Bhuvanesh_Surachari@mentor.com>2022-05-12 17:37:14 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2022-05-19 18:14:49 +0200
commit6c5ba7395b1badce5e0b8e597907751e952646cb (patch)
tree14f53d97d9889bc109365dfd1efea8865518894a /drivers/usb/core
parentdce49449e04ff150838a31386ee65917beb9ebb5 (diff)
downloadlinux-6c5ba7395b1badce5e0b8e597907751e952646cb.tar.gz
linux-6c5ba7395b1badce5e0b8e597907751e952646cb.tar.bz2
linux-6c5ba7395b1badce5e0b8e597907751e952646cb.zip
usb: hub: Simplify error and success path in port_over_current_notify
kasprintf() returns NULL or valid pointer. Since kfree() can handle NULL pointer condition, simplify error and success paths in function port_over_current_notify() by removing multiple error path labels. Signed-off-by: Bhuvanesh Surachari <Bhuvanesh_Surachari@mentor.com> Signed-off-by: Eugeniu Rosca <erosca@de.adit-jv.com> Link: https://lore.kernel.org/r/1652369834-4480-1-git-send-email-erosca@de.adit-jv.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/core')
-rw-r--r--drivers/usb/core/hub.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 7781b2d31473..68e9121c1878 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -5511,7 +5511,7 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1,
/* Handle notifying userspace about hub over-current events */
static void port_over_current_notify(struct usb_port *port_dev)
{
- char *envp[3];
+ char *envp[3] = { NULL, NULL, NULL };
struct device *hub_dev;
char *port_dev_path;
@@ -5528,20 +5528,18 @@ static void port_over_current_notify(struct usb_port *port_dev)
envp[0] = kasprintf(GFP_KERNEL, "OVER_CURRENT_PORT=%s", port_dev_path);
if (!envp[0])
- goto exit_path;
+ goto exit;
envp[1] = kasprintf(GFP_KERNEL, "OVER_CURRENT_COUNT=%u",
port_dev->over_current_count);
if (!envp[1])
goto exit;
- envp[2] = NULL;
kobject_uevent_env(&hub_dev->kobj, KOBJ_CHANGE, envp);
- kfree(envp[1]);
exit:
+ kfree(envp[1]);
kfree(envp[0]);
-exit_path:
kfree(port_dev_path);
}