LKML Archive on
help / color / mirror / Atom feed
From: Wong Vee Khee <>
To: Jose Abreu <>,
	Andrew Lunn <>,
	Heiner Kallweit <>,
	Russell King <>,
	"David S . Miller" <>,
	Jakub Kicinski <>
	Vladimir Oltean <>
Subject: [PATCH net-next 1/1] net: pcs: xpcs: fix error handling on failed to allocate memory
Date: Tue, 10 Aug 2021 16:58:12 +0800	[thread overview]
Message-ID: <> (raw)

Drivers such as sja1105 and stmmac that call xpcs_create() expects an
error returned by the pcs-xpcs module, but this was not the case on
failed to allocate memory.

Fixed this by returning an -ENOMEM instead of a NULL pointer.

Cc: Vladimir Oltean <>
Signed-off-by: Wong Vee Khee <>
 drivers/net/pcs/pcs-xpcs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/pcs/pcs-xpcs.c b/drivers/net/pcs/pcs-xpcs.c
index 63fda3fc40aa..4bd61339823c 100644
--- a/drivers/net/pcs/pcs-xpcs.c
+++ b/drivers/net/pcs/pcs-xpcs.c
@@ -1089,7 +1089,7 @@ struct dw_xpcs *xpcs_create(struct mdio_device *mdiodev,
 	xpcs = kzalloc(sizeof(*xpcs), GFP_KERNEL);
 	if (!xpcs)
-		return NULL;
+		return ERR_PTR(-ENOMEM);
 	xpcs->mdiodev = mdiodev;

             reply	other threads:[~2021-08-10  8:53 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-10  8:58 Wong Vee Khee [this message]
2021-08-11 11:47 ` [PATCH net-next 1/1] net: pcs: xpcs: fix error handling on failed to allocate memory Vladimir Oltean
2021-08-11 22:10 ` patchwork-bot+netdevbpf

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:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \ \ \ \ \ \ \ \ \

* 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;
as well as URLs for NNTP newsgroup(s).