aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/message
diff options
context:
space:
mode:
authorWang Chen <wangchen@cn.fujitsu.com>2008-07-24 00:30:01 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-07-24 13:47:30 -0400
commit0293902a4d66fab27d0ddcc0766e05dae68f004e (patch)
tree3a02e64ec212aa568eeaeae38065877e36a0c833 /drivers/message
parentf700d6e5e5549cb9349d22043f4bd153792c621f (diff)
I2O: handle sysfs_create_link() failures
Compile warning: ignoring return value of `sysfs_create_link', declared with attribute warn_unused_result. If sysfs_create_link failed, take care of the return value and do some error handle after the failure. Since sysfs_remove_link() will check whether a link exists, when removing the link in error path, we don't need to care whether a link was created. Signed-off-by: Wang Chen <wangchen@cn.fujitsu.com> Cc: Markus Lidel <Markus.Lidel@shadowconnect.com> Cc: Jens Axboe <jens.axboe@oracle.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/message')
-rw-r--r--drivers/message/i2o/device.c54
1 files changed, 42 insertions, 12 deletions
diff --git a/drivers/message/i2o/device.c b/drivers/message/i2o/device.c
index 489d7c5c4965..8774c670e668 100644
--- a/drivers/message/i2o/device.c
+++ b/drivers/message/i2o/device.c
@@ -243,29 +243,41 @@ static int i2o_device_add(struct i2o_controller *c, i2o_lct_entry *entry)
243 243
244 /* create user entries for this device */ 244 /* create user entries for this device */
245 tmp = i2o_iop_find_device(i2o_dev->iop, i2o_dev->lct_data.user_tid); 245 tmp = i2o_iop_find_device(i2o_dev->iop, i2o_dev->lct_data.user_tid);
246 if (tmp && (tmp != i2o_dev)) 246 if (tmp && (tmp != i2o_dev)) {
247 sysfs_create_link(&i2o_dev->device.kobj, &tmp->device.kobj, 247 rc = sysfs_create_link(&i2o_dev->device.kobj,
248 "user"); 248 &tmp->device.kobj, "user");
249 if (rc)
250 goto unreg_dev;
251 }
249 252
250 /* create user entries refering to this device */ 253 /* create user entries refering to this device */
251 list_for_each_entry(tmp, &c->devices, list) 254 list_for_each_entry(tmp, &c->devices, list)
252 if ((tmp->lct_data.user_tid == i2o_dev->lct_data.tid) 255 if ((tmp->lct_data.user_tid == i2o_dev->lct_data.tid)
253 && (tmp != i2o_dev)) 256 && (tmp != i2o_dev)) {
254 sysfs_create_link(&tmp->device.kobj, 257 rc = sysfs_create_link(&tmp->device.kobj,
255 &i2o_dev->device.kobj, "user"); 258 &i2o_dev->device.kobj, "user");
259 if (rc)
260 goto rmlink1;
261 }
256 262
257 /* create parent entries for this device */ 263 /* create parent entries for this device */
258 tmp = i2o_iop_find_device(i2o_dev->iop, i2o_dev->lct_data.parent_tid); 264 tmp = i2o_iop_find_device(i2o_dev->iop, i2o_dev->lct_data.parent_tid);
259 if (tmp && (tmp != i2o_dev)) 265 if (tmp && (tmp != i2o_dev)) {
260 sysfs_create_link(&i2o_dev->device.kobj, &tmp->device.kobj, 266 rc = sysfs_create_link(&i2o_dev->device.kobj,
261 "parent"); 267 &tmp->device.kobj, "parent");
268 if (rc)
269 goto rmlink1;
270 }
262 271
263 /* create parent entries refering to this device */ 272 /* create parent entries refering to this device */
264 list_for_each_entry(tmp, &c->devices, list) 273 list_for_each_entry(tmp, &c->devices, list)
265 if ((tmp->lct_data.parent_tid == i2o_dev->lct_data.tid) 274 if ((tmp->lct_data.parent_tid == i2o_dev->lct_data.tid)
266 && (tmp != i2o_dev)) 275 && (tmp != i2o_dev)) {
267 sysfs_create_link(&tmp->device.kobj, 276 rc = sysfs_create_link(&tmp->device.kobj,
268 &i2o_dev->device.kobj, "parent"); 277 &i2o_dev->device.kobj, "parent");
278 if (rc)
279 goto rmlink2;
280 }
269 281
270 i2o_driver_notify_device_add_all(i2o_dev); 282 i2o_driver_notify_device_add_all(i2o_dev);
271 283
@@ -273,6 +285,24 @@ static int i2o_device_add(struct i2o_controller *c, i2o_lct_entry *entry)
273 285
274 return 0; 286 return 0;
275 287
288rmlink2:
289 /* If link creating failed halfway, we loop whole list to cleanup.
290 * And we don't care wrong removing of link, because sysfs_remove_link
291 * will take care of it.
292 */
293 list_for_each_entry(tmp, &c->devices, list) {
294 if (tmp->lct_data.parent_tid == i2o_dev->lct_data.tid)
295 sysfs_remove_link(&tmp->device.kobj, "parent");
296 }
297 sysfs_remove_link(&i2o_dev->device.kobj, "parent");
298rmlink1:
299 list_for_each_entry(tmp, &c->devices, list)
300 if (tmp->lct_data.user_tid == i2o_dev->lct_data.tid)
301 sysfs_remove_link(&tmp->device.kobj, "user");
302 sysfs_remove_link(&i2o_dev->device.kobj, "user");
303unreg_dev:
304 list_del(&i2o_dev->list);
305 device_unregister(&i2o_dev->device);
276err: 306err:
277 kfree(i2o_dev); 307 kfree(i2o_dev);
278 return rc; 308 return rc;