From: Eugeniu Rosca <erosca@de.adit-jv.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Alan Stern <stern@rowland.harvard.edu>,
Mathias Nyman <mathias.nyman@linux.intel.com>,
Kai-Heng Feng <kai.heng.feng@canonical.com>,
Rajat Jain <rajatja@google.com>, Andrew Lunn <andrew@lunn.ch>,
Chris Chiu <chris.chiu@canonical.com>,
Marek Szyprowski <m.szyprowski@samsung.com>,
<linux-usb@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Cc: Naveen kumar Sunkari <naveenkumar.sunkari@in.bosch.com>,
Bhuvanesh Surachari <Bhuvanesh_Surachari@mentor.com>,
Eugeniu Rosca <erosca@de.adit-jv.com>,
Eugeniu Rosca <rosca.eugeniu@gmail.com>
Subject: [PATCH] usb: hub: Simplify error and success path in port_over_current_notify
Date: Thu, 12 May 2022 13:15:27 +0200 [thread overview]
Message-ID: <1652354127-3499-1-git-send-email-erosca@de.adit-jv.com> (raw)
From: Bhuvanesh Surachari <Bhuvanesh_Surachari@mentor.com>
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>
---
drivers/usb/core/hub.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 1460857026e0..9ab8abf14790 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;
@@ -5533,15 +5533,13 @@ static void port_over_current_notify(struct usb_port *port_dev)
envp[1] = kasprintf(GFP_KERNEL, "OVER_CURRENT_COUNT=%u",
port_dev->over_current_count);
if (!envp[1])
- goto exit;
+ goto exit_path;
- envp[2] = NULL;
kobject_uevent_env(&hub_dev->kobj, KOBJ_CHANGE, envp);
+exit_path:
kfree(envp[1]);
-exit:
kfree(envp[0]);
-exit_path:
kfree(port_dev_path);
}
--
2.36.0
next reply other threads:[~2022-05-12 11:20 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-12 11:15 Eugeniu Rosca [this message]
2022-05-12 11:38 ` [PATCH] usb: hub: Simplify error and success path in port_over_current_notify Greg Kroah-Hartman
2022-05-12 15:44 ` Eugeniu Rosca
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1652354127-3499-1-git-send-email-erosca@de.adit-jv.com \
--to=erosca@de.adit-jv.com \
--cc=Bhuvanesh_Surachari@mentor.com \
--cc=andrew@lunn.ch \
--cc=chris.chiu@canonical.com \
--cc=gregkh@linuxfoundation.org \
--cc=kai.heng.feng@canonical.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=m.szyprowski@samsung.com \
--cc=mathias.nyman@linux.intel.com \
--cc=naveenkumar.sunkari@in.bosch.com \
--cc=rajatja@google.com \
--cc=rosca.eugeniu@gmail.com \
--cc=stern@rowland.harvard.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox