]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
staging: gpib: Fix error handling paths in cb_gpib_probe()
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Sat, 5 Jul 2025 09:52:33 +0000 (11:52 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 9 Jul 2025 11:11:49 +0000 (13:11 +0200)
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: e9dc69956d4d ("staging: gpib: Add Computer Boards GPIB driver")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Link: https://lore.kernel.org/r/bf89d6f2f8b8c680720d02061fc4ebdd805deca8.1751709098.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/gpib/cb7210/cb7210.c

index 298ed306189df5c3eca2434485563b9a5c8866c5..3e2397898a9ba29506ed5beb4d353fbd0d768e78 100644 (file)
@@ -1184,8 +1184,7 @@ struct local_info {
 static int cb_gpib_probe(struct pcmcia_device *link)
 {
        struct local_info *info;
-
-//     int ret, i;
+       int ret;
 
        /* Allocate space for private device-specific data */
        info = kzalloc(sizeof(*info), GFP_KERNEL);
@@ -1211,8 +1210,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