public inbox for linux-tegra@vger.kernel.org
 help / color / mirror / Atom feed
From: williamsukatube@163.com
To: linux-phy@lists.infradead.org, linux-tegra@vger.kernel.org,
	linux-kernel@vger.kernel.org
Cc: jckuo@nvidia.com, kishon@ti.com, vkoul@kernel.org,
	thierry.reding@gmail.com, jonathanh@nvidia.com,
	William Dean <williamsukatube@gmail.com>,
	Hacash Robot <hacashRobot@santino.com>
Subject: [PATCH] phy: tegra: xusb: check the return value of devm_kzalloc() in tegra_xusb_setup_usb_role_switch()
Date: Sat, 23 Jul 2022 11:41:30 +0800	[thread overview]
Message-ID: <20220723034130.2952016-1-williamsukatube@163.com> (raw)

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


             reply	other threads:[~2022-07-23  3:42 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-23  3:41 williamsukatube [this message]
2022-08-30  7:19 ` [PATCH] phy: tegra: xusb: check the return value of devm_kzalloc() in tegra_xusb_setup_usb_role_switch() 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=20220723034130.2952016-1-williamsukatube@163.com \
    --to=williamsukatube@163.com \
    --cc=hacashRobot@santino.com \
    --cc=jckuo@nvidia.com \
    --cc=jonathanh@nvidia.com \
    --cc=kishon@ti.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-phy@lists.infradead.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=thierry.reding@gmail.com \
    --cc=vkoul@kernel.org \
    --cc=williamsukatube@gmail.com \
    /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