public inbox for linux-tegra@vger.kernel.org
 help / color / mirror / Atom feed
From: Dmitry Osipenko <digetx@gmail.com>
To: Miaoqian Lin <linmq006@gmail.com>
Cc: JC Kuo <jckuo@nvidia.com>, Kishon Vijay Abraham I <kishon@ti.com>,
	Vinod Koul <vkoul@kernel.org>,
	Thierry Reding <thierry.reding@gmail.com>,
	Jonathan Hunter <jonathanh@nvidia.com>,
	linux-phy@lists.infradead.org, linux-tegra@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] phy: tegra: xusb: Fix NULL vs IS_ERR_OR_NULL checking
Date: Sun, 12 Dec 2021 17:31:35 +0300	[thread overview]
Message-ID: <942f943c-9ec8-9887-aa6d-4d133821beca@gmail.com> (raw)
In-Reply-To: <20211212065014.31660-1-linmq006@gmail.com>

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);

  reply	other threads:[~2021-12-12 14:31 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-12  6:50 [PATCH] phy: tegra: xusb: Fix NULL vs IS_ERR_OR_NULL checking Miaoqian Lin
2021-12-12 14:31 ` Dmitry Osipenko [this message]
2021-12-13  2:05   ` [PATCH v2] phy: tegra: xusb: Fix return value of tegra_xusb_find_port_node function Miaoqian Lin
2021-12-13 10:24     ` Thierry Reding
2021-12-14  7: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=942f943c-9ec8-9887-aa6d-4d133821beca@gmail.com \
    --to=digetx@gmail.com \
    --cc=jckuo@nvidia.com \
    --cc=jonathanh@nvidia.com \
    --cc=kishon@ti.com \
    --cc=linmq006@gmail.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 \
    /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