Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1682910 > unrolled thread

[PATCH] arcnet: com20020-pci: Fix an error handling path in 'com20020pci_probe()'

Started byChristophe JAILLET <christophe.jaillet@wanadoo.fr>
First post2017-07-07 07:00 +0200
Last post2017-07-07 10:30 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] arcnet: com20020-pci: Fix an error handling path in 'com20020pci_probe()' Christophe JAILLET <christophe.jaillet@wanadoo.fr> - 2017-07-07 07:00 +0200
    Re: [PATCH] arcnet: com20020-pci: Fix an error handling path in  'com20020pci_probe()' David Miller <davem@davemloft.net> - 2017-07-07 10:30 +0200

#1682910 — [PATCH] arcnet: com20020-pci: Fix an error handling path in 'com20020pci_probe()'

FromChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Date2017-07-07 07:00 +0200
Subject[PATCH] arcnet: com20020-pci: Fix an error handling path in 'com20020pci_probe()'
Message-ID<u0twZ-7l9-7@gated-at.bofh.it>
If this memory allocation fails, we should go through the error handling
path as done everywhere else in this function before returning.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 drivers/net/arcnet/com20020-pci.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/arcnet/com20020-pci.c b/drivers/net/arcnet/com20020-pci.c
index 239de38fbd6a..8e89a2ac071e 100644
--- a/drivers/net/arcnet/com20020-pci.c
+++ b/drivers/net/arcnet/com20020-pci.c
@@ -196,8 +196,10 @@ static int com20020pci_probe(struct pci_dev *pdev,
 
 		card = devm_kzalloc(&pdev->dev, sizeof(struct com20020_dev),
 				    GFP_KERNEL);
-		if (!card)
-			return -ENOMEM;
+		if (!card) {
+			ret = -ENOMEM;
+			goto out_port;
+		}
 
 		card->index = i;
 		card->pci_priv = priv;
-- 
2.11.0

[toc] | [next] | [standalone]


#1683016 — Re: [PATCH] arcnet: com20020-pci: Fix an error handling path in 'com20020pci_probe()'

FromDavid Miller <davem@davemloft.net>
Date2017-07-07 10:30 +0200
SubjectRe: [PATCH] arcnet: com20020-pci: Fix an error handling path in 'com20020pci_probe()'
Message-ID<u0wOe-1h8-3@gated-at.bofh.it>
In reply to#1682910
From: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Date: Fri,  7 Jul 2017 06:56:16 +0200

> If this memory allocation fails, we should go through the error handling
> path as done everywhere else in this function before returning.
> 
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

This is really the tip of the iceberg here and this function's cleanup
really needs to be shored up more completely than this.

If the allocation of 'card' succeeds, and one of the "goto out_port"
paths are taken, 'card' is leaked because the last thing performed
is linking it into the list inside of 'priv'.

Anyways, I'll apply this but there are so many more leaks here.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web