[PATCH] staging: gpib: Fix error handling paths in cb_gpib_probe()

Christophe JAILLET posted 1 patch 1 year, 3 months ago
There is a newer version of this series
drivers/staging/gpib/cb7210/cb7210.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
[PATCH] staging: gpib: Fix error handling paths in cb_gpib_probe()
Posted by Christophe JAILLET 1 year, 3 months ago
If cb_gpib_config() fails, 'info' needs to be freed, as already done in the
remove function.

While at it, remove a pointless comment related to gpib_attach().

Fixes: 6f1067cfbee7 ("mfd: Add Congatec Board Controller driver")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
*NOT* compile tested, so provided as-is

It does not compile on x86_64 because of some missing includes. I've not
seen if it was dedicated to a specific arch, so couldn't cross-compile
---
 drivers/staging/gpib/cb7210/cb7210.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/gpib/cb7210/cb7210.c b/drivers/staging/gpib/cb7210/cb7210.c
index c827d03dacf5..98f20dab320a 100644
--- a/drivers/staging/gpib/cb7210/cb7210.c
+++ b/drivers/staging/gpib/cb7210/cb7210.c
@@ -1194,8 +1194,7 @@ struct local_info {
 static int cb_gpib_probe(struct pcmcia_device *link)
 {
 	struct local_info *info;
-
-//	int ret, i;
+	int ret;
 
 	DEBUG(0, "%s(0x%p)\n", __func__, link);
 
@@ -1223,8 +1222,16 @@ static int cb_gpib_probe(struct pcmcia_device *link)
 
 	/* Register with Card Services */
 	curr_dev = link;
-	return cb_gpib_config(link);
-} /* gpib_attach */
+	ret = cb_gpib_config(link);
+	if (ret)
+		goto free_info;
+
+	return 0;
+
+free_info:
+	kfree(info);
+	return ret;
+}
 
 /*
  *   This deletes a driver "instance".  The device is de-registered
-- 
2.47.0
Re: [PATCH] staging: gpib: Fix error handling paths in cb_gpib_probe()
Posted by Thomas Richard 1 year, 3 months ago
Hello Christophe,

On 10/26/24 13:03, Christophe JAILLET wrote:
> If cb_gpib_config() fails, 'info' needs to be freed, as already done in the
> remove function.
> 
> While at it, remove a pointless comment related to gpib_attach().
> 
> Fixes: 6f1067cfbee7 ("mfd: Add Congatec Board Controller driver")

The Fixes tag is not correct.
I guess you did a wrong copy-paste as you sent a patch for the CGBC MFD
driver few minutes before :)

Regards,

Thomas