Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

staging: gpib: Fix error handling paths in cb_gpib_probe()

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>

authored by

Christophe JAILLET and committed by
Greg Kroah-Hartman
1b0ee85e 4f7ac4d0

+11 -4
+11 -4
drivers/staging/gpib/cb7210/cb7210.c
··· 1184 1184 static int cb_gpib_probe(struct pcmcia_device *link) 1185 1185 { 1186 1186 struct local_info *info; 1187 - 1188 - // int ret, i; 1187 + int ret; 1189 1188 1190 1189 /* Allocate space for private device-specific data */ 1191 1190 info = kzalloc(sizeof(*info), GFP_KERNEL); ··· 1210 1211 1211 1212 /* Register with Card Services */ 1212 1213 curr_dev = link; 1213 - return cb_gpib_config(link); 1214 - } /* gpib_attach */ 1214 + ret = cb_gpib_config(link); 1215 + if (ret) 1216 + goto free_info; 1217 + 1218 + return 0; 1219 + 1220 + free_info: 1221 + kfree(info); 1222 + return ret; 1223 + } 1215 1224 1216 1225 /* 1217 1226 * This deletes a driver "instance". The device is de-registered