[PATCH] ARCNET: Add missing error check for devm_kzalloc

Subsystems: arcnet network layer, networking drivers, the rest

STALE4276d

2 messages, 2 authors, 2015-02-05 · open the first message on its own page

[PATCH] ARCNET: Add missing error check for devm_kzalloc

From: Kiran Padwal <hidden>
Date: 2015-02-05 11:33:33

This patch add a missing check on the return value of devm_kzalloc,
which would cause a NULL pointer dereference in a OOM situation.

Signed-off-by: Kiran Padwal <redacted>
---
 drivers/net/arcnet/com20020-pci.c |    3 +++
 1 file changed, 3 insertions(+)
diff --git a/drivers/net/arcnet/com20020-pci.c b/drivers/net/arcnet/com20020-pci.c
index 6c99ff0..945f532 100644
--- a/drivers/net/arcnet/com20020-pci.c
+++ b/drivers/net/arcnet/com20020-pci.c
@@ -78,6 +78,9 @@ static int com20020pci_probe(struct pci_dev *pdev, const struct pci_device_id *i
 
 	priv = devm_kzalloc(&pdev->dev, sizeof(struct com20020_priv),
 			    GFP_KERNEL);
+	if (!priv)
+		return -ENOMEM;
+
 	ci = (struct com20020_pci_card_info *)id->driver_data;
 	priv->ci = ci;
 
-- 
1.7.9.5

Re: [PATCH] ARCNET: Add missing error check for devm_kzalloc

From: David Miller <davem@davemloft.net>
Date: 2015-02-05 23:53:49

From: Kiran Padwal <redacted>
Date: Thu,  5 Feb 2015 17:01:37 +0530
This patch add a missing check on the return value of devm_kzalloc,
which would cause a NULL pointer dereference in a OOM situation.

Signed-off-by: Kiran Padwal <redacted>
Applied, thanks.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help