From: Claudiu Beznea <claudiu.beznea@microchip.com>
To: <jckuo@nvidia.com>, <vkoul@kernel.org>, <kishon@kernel.org>,
<thierry.reding@gmail.com>, <jonathanh@nvidia.com>,
<nkristam@nvidia.com>
Cc: <linux-phy@lists.infradead.org>, <linux-tegra@vger.kernel.org>,
<linux-kernel@vger.kernel.org>,
Claudiu Beznea <claudiu.beznea@microchip.com>
Subject: [PATCH] phy: tegra: xusb: check return value of devm_kzalloc()
Date: Wed, 31 May 2023 10:39:50 +0300 [thread overview]
Message-ID: <20230531073950.145339-1-claudiu.beznea@microchip.com> (raw)
devm_kzalloc() returns a pointer to dynamically allocated memory.
Pointer could be NULL in case allocation fails. Check pointer validity.
Identified with coccinelle (kmerr.cocci script).
Fixes: f67213cee2b3 ("phy: tegra: xusb: Add usb-role-switch support")
Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
---
Hi,
This has been addressed using kmerr.cocci script proposed for update
at [1].
Thank you,
Claudiu Beznea
[1] https://lore.kernel.org/all/20230530074044.1603426-1-claudiu.beznea@microchip.com/
drivers/phy/tegra/xusb.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/phy/tegra/xusb.c b/drivers/phy/tegra/xusb.c
index ec335668563d..fe72bc74e7bc 100644
--- a/drivers/phy/tegra/xusb.c
+++ b/drivers/phy/tegra/xusb.c
@@ -675,6 +675,9 @@ static int tegra_xusb_setup_usb_role_switch(struct tegra_xusb_port *port)
port->dev.driver = devm_kzalloc(&port->dev,
sizeof(struct device_driver),
GFP_KERNEL);
+ if (!port->dev.driver)
+ return -ENOMEM;
+
port->dev.driver->owner = THIS_MODULE;
port->usb_role_sw = usb_role_switch_register(&port->dev,
--
2.34.1
--
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy
WARNING: multiple messages have this Message-ID (diff)
From: Claudiu Beznea <claudiu.beznea@microchip.com>
To: <jckuo@nvidia.com>, <vkoul@kernel.org>, <kishon@kernel.org>,
<thierry.reding@gmail.com>, <jonathanh@nvidia.com>,
<nkristam@nvidia.com>
Cc: <linux-phy@lists.infradead.org>, <linux-tegra@vger.kernel.org>,
<linux-kernel@vger.kernel.org>,
Claudiu Beznea <claudiu.beznea@microchip.com>
Subject: [PATCH] phy: tegra: xusb: check return value of devm_kzalloc()
Date: Wed, 31 May 2023 10:39:50 +0300 [thread overview]
Message-ID: <20230531073950.145339-1-claudiu.beznea@microchip.com> (raw)
devm_kzalloc() returns a pointer to dynamically allocated memory.
Pointer could be NULL in case allocation fails. Check pointer validity.
Identified with coccinelle (kmerr.cocci script).
Fixes: f67213cee2b3 ("phy: tegra: xusb: Add usb-role-switch support")
Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
---
Hi,
This has been addressed using kmerr.cocci script proposed for update
at [1].
Thank you,
Claudiu Beznea
[1] https://lore.kernel.org/all/20230530074044.1603426-1-claudiu.beznea@microchip.com/
drivers/phy/tegra/xusb.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/phy/tegra/xusb.c b/drivers/phy/tegra/xusb.c
index ec335668563d..fe72bc74e7bc 100644
--- a/drivers/phy/tegra/xusb.c
+++ b/drivers/phy/tegra/xusb.c
@@ -675,6 +675,9 @@ static int tegra_xusb_setup_usb_role_switch(struct tegra_xusb_port *port)
port->dev.driver = devm_kzalloc(&port->dev,
sizeof(struct device_driver),
GFP_KERNEL);
+ if (!port->dev.driver)
+ return -ENOMEM;
+
port->dev.driver->owner = THIS_MODULE;
port->usb_role_sw = usb_role_switch_register(&port->dev,
--
2.34.1
next reply other threads:[~2023-05-31 7:40 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-31 7:39 Claudiu Beznea [this message]
2023-05-31 7:39 ` [PATCH] phy: tegra: xusb: check return value of devm_kzalloc() Claudiu Beznea
2023-06-01 9:39 ` Thierry Reding
2023-06-01 9:39 ` Thierry Reding
2023-06-21 17:37 ` Vinod Koul
2023-06-21 17:37 ` Vinod Koul
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=20230531073950.145339-1-claudiu.beznea@microchip.com \
--to=claudiu.beznea@microchip.com \
--cc=jckuo@nvidia.com \
--cc=jonathanh@nvidia.com \
--cc=kishon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-phy@lists.infradead.org \
--cc=linux-tegra@vger.kernel.org \
--cc=nkristam@nvidia.com \
--cc=thierry.reding@gmail.com \
--cc=vkoul@kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.