From patchwork Mon Mar 5 21:53:08 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: Hardy SRU - bsg: fix sysfs link remove warning Date: Mon, 05 Mar 2012 11:53:08 -0000 From: Tim Gardner X-Patchwork-Id: 144781 Message-Id: <4F5535C4.50707@canonical.com> To: kernel-team >From 5242342fbb22946413367c72d1b6f0267fe3b6f1 Mon Sep 17 00:00:00 2001 From: Tim Gardner Date: Mon, 5 Mar 2012 14:49:54 -0700 Subject: [PATCH Hardy SRU] bsg: fix sysfs link remove warning We create "bsg" link if q->kobj.sd is not NULL, so remove it only when the same condition is true. Fixes: WARNING: at fs/sysfs/inode.c:323 sysfs_hash_and_remove+0x2b/0x77() sysfs: can not remove 'bsg', no directory Call Trace: [] warn_slowpath_common+0x6a/0x7f [] ? sysfs_hash_and_remove+0x2b/0x77 [] warn_slowpath_fmt+0x2b/0x2f [] sysfs_hash_and_remove+0x2b/0x77 [] sysfs_remove_link+0x20/0x23 [] bsg_unregister_queue+0x40/0x6d [] __scsi_remove_device+0x31/0x9d [] scsi_forget_host+0x41/0x52 [] scsi_remove_host+0x71/0xe0 [] quiesce_and_remove_host+0x51/0x83 [usb_storage] [] usb_stor_disconnect+0x18/0x22 [usb_storage] [] usb_unbind_interface+0x4e/0x109 [] __device_release_driver+0x6b/0xa6 [] device_release_driver+0x17/0x22 [] bus_remove_device+0xd6/0xe6 [] device_del+0xf2/0x137 [] usb_disable_device+0x94/0x1a0 Signed-off-by: Stanislaw Gruszka Signed-off-by: Jens Axboe (backported from commit 37b40adf2d1b4a5e51323be73ccf8ddcf3f15dd3) Signed-off-by: Tim Gardner --- block/bsg.c | 3 ++- debian/binary-custom.d/openvz/src/block/bsg.c | 3 ++- debian/binary-custom.d/xen/src/block/bsg.c | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/block/bsg.c b/block/bsg.c index 31f85dd..180a406 100644 --- a/block/bsg.c +++ b/block/bsg.c @@ -929,7 +929,8 @@ void bsg_unregister_queue(struct request_queue *q) mutex_lock(&bsg_mutex); idr_remove(&bsg_minor_idr, bcd->minor); - sysfs_remove_link(&q->kobj, "bsg"); + if (q->kobj.sd) + sysfs_remove_link(&q->kobj, "bsg"); class_device_unregister(bcd->class_dev); put_device(bcd->dev); bcd->class_dev = NULL; diff --git a/debian/binary-custom.d/openvz/src/block/bsg.c b/debian/binary-custom.d/openvz/src/block/bsg.c index 31f85dd..180a406 100644 --- a/debian/binary-custom.d/openvz/src/block/bsg.c +++ b/debian/binary-custom.d/openvz/src/block/bsg.c @@ -929,7 +929,8 @@ void bsg_unregister_queue(struct request_queue *q) mutex_lock(&bsg_mutex); idr_remove(&bsg_minor_idr, bcd->minor); - sysfs_remove_link(&q->kobj, "bsg"); + if (q->kobj.sd) + sysfs_remove_link(&q->kobj, "bsg"); class_device_unregister(bcd->class_dev); put_device(bcd->dev); bcd->class_dev = NULL; diff --git a/debian/binary-custom.d/xen/src/block/bsg.c b/debian/binary-custom.d/xen/src/block/bsg.c index 31f85dd..180a406 100644 --- a/debian/binary-custom.d/xen/src/block/bsg.c +++ b/debian/binary-custom.d/xen/src/block/bsg.c @@ -929,7 +929,8 @@ void bsg_unregister_queue(struct request_queue *q) mutex_lock(&bsg_mutex); idr_remove(&bsg_minor_idr, bcd->minor); - sysfs_remove_link(&q->kobj, "bsg"); + if (q->kobj.sd) + sysfs_remove_link(&q->kobj, "bsg"); class_device_unregister(bcd->class_dev); put_device(bcd->dev); bcd->class_dev = NULL; -- 1.7.9