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

rio: warn_unused_result warnings fix

Adding failure path for the following two cases.

warning: ignoring return value of 'device_add', declared with attribute warn_unused_result
warning: ignoring return value of 'sysfs_create_bin_file', declared with attribute warn_unused_result

Signed-off-by: Li Yang <leoli@freescale.com>
Signed-off-by: Kumar Gala <galak@kernel.crashing.org>

authored by

Yang Li and committed by
Kumar Gala
5f28c520 7b9edb9d

+30 -19
+26 -17
drivers/rapidio/rio-scan.c
··· 263 263 * device to the RIO device list. Creates the generic sysfs nodes 264 264 * for an RIO device. 265 265 */ 266 - static void __devinit rio_add_device(struct rio_dev *rdev) 266 + static int __devinit rio_add_device(struct rio_dev *rdev) 267 267 { 268 - device_add(&rdev->dev); 268 + int err; 269 + 270 + err = device_add(&rdev->dev); 271 + if (err) 272 + return err; 269 273 270 274 spin_lock(&rio_global_list_lock); 271 275 list_add_tail(&rdev->global_list, &rio_devices); 272 276 spin_unlock(&rio_global_list_lock); 273 277 274 278 rio_create_sysfs_dev_files(rdev); 279 + 280 + return 0; 275 281 } 276 282 277 283 /** ··· 300 294 struct rio_mport *port, u16 destid, 301 295 u8 hopcount, int do_enum) 302 296 { 297 + int ret = 0; 303 298 struct rio_dev *rdev; 304 - struct rio_switch *rswitch; 299 + struct rio_switch *rswitch = NULL; 305 300 int result, rdid; 306 301 307 302 rdev = kzalloc(sizeof(struct rio_dev), GFP_KERNEL); 308 303 if (!rdev) 309 - goto out; 304 + return NULL; 310 305 311 306 rdev->net = net; 312 307 rio_mport_read_config_32(port, destid, hopcount, RIO_DEV_ID_CAR, ··· 350 343 rio_mport_read_config_32(port, destid, hopcount, 351 344 RIO_SWP_INFO_CAR, &rdev->swpinfo); 352 345 rswitch = kmalloc(sizeof(struct rio_switch), GFP_KERNEL); 353 - if (!rswitch) { 354 - kfree(rdev); 355 - rdev = NULL; 356 - goto out; 357 - } 346 + if (!rswitch) 347 + goto cleanup; 358 348 rswitch->switchid = next_switchid; 359 349 rswitch->hopcount = hopcount; 360 350 rswitch->destid = destid; 361 351 rswitch->route_table = kzalloc(sizeof(u8)* 362 352 RIO_MAX_ROUTE_ENTRIES(port->sys_size), 363 353 GFP_KERNEL); 364 - if (!rswitch->route_table) { 365 - kfree(rdev); 366 - rdev = NULL; 367 - kfree(rswitch); 368 - goto out; 369 - } 354 + if (!rswitch->route_table) 355 + goto cleanup; 370 356 /* Initialize switch route table */ 371 357 for (rdid = 0; rdid < RIO_MAX_ROUTE_ENTRIES(port->sys_size); 372 358 rdid++) ··· 390 390 rio_init_dbell_res(&rdev->riores[RIO_DOORBELL_RESOURCE], 391 391 0, 0xffff); 392 392 393 - rio_add_device(rdev); 393 + ret = rio_add_device(rdev); 394 + if (ret) 395 + goto cleanup; 394 396 395 - out: 396 397 return rdev; 398 + 399 + cleanup: 400 + if (rswitch) { 401 + kfree(rswitch->route_table); 402 + kfree(rswitch); 403 + } 404 + kfree(rdev); 405 + return NULL; 397 406 } 398 407 399 408 /**
+4 -2
drivers/rapidio/rio-sysfs.c
··· 214 214 */ 215 215 int rio_create_sysfs_dev_files(struct rio_dev *rdev) 216 216 { 217 - sysfs_create_bin_file(&rdev->dev.kobj, &rio_config_attr); 217 + int err = 0; 218 218 219 - return 0; 219 + err = sysfs_create_bin_file(&rdev->dev.kobj, &rio_config_attr); 220 + 221 + return err; 220 222 } 221 223 222 224 /**