linux-phy.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] phy: tegra: xusb: check the return value of devm_kzalloc() in tegra_xusb_setup_usb_role_switch()
@ 2022-07-23  3:41 williamsukatube
  2022-08-30  7:19 ` Vinod Koul
  0 siblings, 1 reply; 2+ messages in thread
From: williamsukatube @ 2022-07-23  3:41 UTC (permalink / raw)
  To: linux-phy, linux-tegra, linux-kernel
  Cc: jckuo, kishon, vkoul, thierry.reding, jonathanh, William Dean,
	Hacash Robot

From: William Dean <williamsukatube@gmail.com>

The function devm_kzalloc() in tegra_xusb_setup_usb_role_switch()
can fail, so its return value should be checked.

Fixes: f67213cee2b35 ("phy: tegra: xusb: Add usb-role-switch support")
Reported-by: Hacash Robot <hacashRobot@santino.com>
Signed-off-by: William Dean <williamsukatube@gmail.com>
---
 drivers/phy/tegra/xusb.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/phy/tegra/xusb.c b/drivers/phy/tegra/xusb.c
index aa5237eacd29..e3611fb4c779 100644
--- a/drivers/phy/tegra/xusb.c
+++ b/drivers/phy/tegra/xusb.c
@@ -668,6 +668,8 @@ 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.25.1


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

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

* Re: [PATCH] phy: tegra: xusb: check the return value of devm_kzalloc() in tegra_xusb_setup_usb_role_switch()
  2022-07-23  3:41 [PATCH] phy: tegra: xusb: check the return value of devm_kzalloc() in tegra_xusb_setup_usb_role_switch() williamsukatube
@ 2022-08-30  7:19 ` Vinod Koul
  0 siblings, 0 replies; 2+ messages in thread
From: Vinod Koul @ 2022-08-30  7:19 UTC (permalink / raw)
  To: williamsukatube
  Cc: linux-phy, linux-tegra, linux-kernel, jckuo, kishon,
	thierry.reding, jonathanh, William Dean, Hacash Robot

On 23-07-22, 11:41, williamsukatube@163.com wrote:
> From: William Dean <williamsukatube@gmail.com>
> 
> The function devm_kzalloc() in tegra_xusb_setup_usb_role_switch()
> can fail, so its return value should be checked.
> 
> Fixes: f67213cee2b35 ("phy: tegra: xusb: Add usb-role-switch support")
> Reported-by: Hacash Robot <hacashRobot@santino.com>

Where is this bug report?

> Signed-off-by: William Dean <williamsukatube@gmail.com>
> ---
>  drivers/phy/tegra/xusb.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/phy/tegra/xusb.c b/drivers/phy/tegra/xusb.c
> index aa5237eacd29..e3611fb4c779 100644
> --- a/drivers/phy/tegra/xusb.c
> +++ b/drivers/phy/tegra/xusb.c
> @@ -668,6 +668,8 @@ 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.25.1

-- 
~Vinod

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

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

end of thread, other threads:[~2022-08-30  7:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-07-23  3:41 [PATCH] phy: tegra: xusb: check the return value of devm_kzalloc() in tegra_xusb_setup_usb_role_switch() williamsukatube
2022-08-30  7:19 ` 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).