linux-phy.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] phy: tegra: xusb: check return value of devm_kzalloc()
@ 2023-05-31  7:39 Claudiu Beznea
  2023-06-01  9:39 ` Thierry Reding
  2023-06-21 17:37 ` Vinod Koul
  0 siblings, 2 replies; 3+ messages in thread
From: Claudiu Beznea @ 2023-05-31  7:39 UTC (permalink / raw)
  To: jckuo, vkoul, kishon, thierry.reding, jonathanh, nkristam
  Cc: linux-phy, linux-tegra, linux-kernel, Claudiu Beznea

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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] phy: tegra: xusb: check return value of devm_kzalloc()
  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-21 17:37 ` Vinod Koul
  1 sibling, 0 replies; 3+ messages in thread
From: Thierry Reding @ 2023-06-01  9:39 UTC (permalink / raw)
  To: Claudiu Beznea
  Cc: jckuo, vkoul, kishon, jonathanh, nkristam, linux-phy, linux-tegra,
	linux-kernel


[-- Attachment #1.1: Type: text/plain, Size: 763 bytes --]

On Wed, May 31, 2023 at 10:39:50AM +0300, Claudiu Beznea wrote:
> 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(+)

Acked-by: Thierry Reding <treding@nvidia.com>

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 112 bytes --]

-- 
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] phy: tegra: xusb: check return value of devm_kzalloc()
  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-21 17:37 ` Vinod Koul
  1 sibling, 0 replies; 3+ messages in thread
From: Vinod Koul @ 2023-06-21 17:37 UTC (permalink / raw)
  To: Claudiu Beznea
  Cc: jckuo, kishon, thierry.reding, jonathanh, nkristam, linux-phy,
	linux-tegra, linux-kernel

On 31-05-23, 10:39, Claudiu Beznea wrote:
> 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).

Applied, thanks

-- 
~Vinod

-- 
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-06-21 17:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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-21 17:37 ` Vinod Koul

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).