lkml.org 
[lkml]   [2021]   [Dec]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
SubjectRe: [PATCH] phy: tegra: xusb: Fix NULL vs IS_ERR_OR_NULL checking
From
Date
12.12.2021 09:50, Miaoqian Lin пишет:
> The tegra_xusb_find_port_node() function may return error pointer when
> kasprintf() return NULL. Using IS_ERR_OR_NULL to check the return value
> of tegra_xusb_find_port_node() to catch this.
>
> Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
> ---
> drivers/phy/tegra/xusb.c | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)

Instead of changing the 6 lines and making code less readable, you could
change a single line.

diff --git a/drivers/phy/tegra/xusb.c b/drivers/phy/tegra/xusb.c
index 963de5913e50..aa5237eacd29 100644
--- a/drivers/phy/tegra/xusb.c
+++ b/drivers/phy/tegra/xusb.c
@@ -455,7 +455,7 @@ tegra_xusb_find_port_node(struct tegra_xusb_padctl
*padctl, const char *type,
name = kasprintf(GFP_KERNEL, "%s-%u", type, index);
if (!name) {
of_node_put(ports);
- return ERR_PTR(-ENOMEM);
+ return NULL;
}
np = of_get_child_by_name(ports, name);
kfree(name);
\
 
 \ /
  Last update: 2021-12-12 15:32    [W:0.084 / U:0.064 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site