mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] staging: gpib: Fix error handling paths in cb_gpib_probe()
@ 2024-10-26 11:03 Christophe JAILLET
  2024-10-28  9:40 ` Thomas Richard
  0 siblings, 1 reply; 2+ messages in thread
From: Christophe JAILLET @ 2024-10-26 11:03 UTC (permalink / raw)
  To: Dave Penkler, Greg Kroah-Hartman, Lee Jones, Thomas Richard
  Cc: linux-kernel, kernel-janitors, Christophe JAILLET, linux-staging

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] staging: gpib: Fix error handling paths in cb_gpib_probe()
  2024-10-26 11:03 [PATCH] staging: gpib: Fix error handling paths in cb_gpib_probe() Christophe JAILLET
@ 2024-10-28  9:40 ` Thomas Richard
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Richard @ 2024-10-28  9:40 UTC (permalink / raw)
  To: Christophe JAILLET, Dave Penkler, Greg Kroah-Hartman, Lee Jones
  Cc: linux-kernel, kernel-janitors, linux-staging

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-10-28  9:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-10-26 11:03 [PATCH] staging: gpib: Fix error handling paths in cb_gpib_probe() Christophe JAILLET
2024-10-28  9:40 ` Thomas Richard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®