[PATCH] uss720 fixup refcount position

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



patch is against latest kernel 2.6.38

My testprog uss720test do a lot of bitbang - after hours i got following warning
and my machine lockups

Mar 17 17:32:27 lotus kernel: [ 7049.296037] ------------[ cut here ]------------
Mar 17 17:32:27 lotus kernel: [ 7049.299459] WARNING: at /build/buildd/linux-2.6.38/lib/kref.c:34
kref_get+0x21/0x30()
Mar 17 17:32:27 lotus kernel: [ 7049.302909] Hardware name: ProLiant ML350 G6
Mar 17 17:32:27 lotus kernel: [ 7049.306301] Modules linked in: nfsd nfs lockd exportfs fscache
nfs_acl auth_rpcgss sunrpc radeon uss720 ttm drm_kms_helper ipmi_devintf drm psmouse ppdev hpilo
serio_raw ipmi_si i7core
_edac edac_core ipmi_msghandler i2c_algo_bit parport shpchp power_meter usbhid hid tg3 e1000e hpsa
Mar 17 17:32:27 lotus kernel: [ 7049.317837] Pid: 1021, comm: uss720test Not tainted 2.6.38
Mar 17 17:32:27 lotus kernel: [ 7049.321689] Call Trace:
Mar 17 17:32:27 lotus kernel: [ 7049.325560]  [<c1058c92>] ? warn_slowpath_common+0x72/0xa0
Mar 17 17:32:27 lotus kernel: [ 7049.329420]  [<c127fbc1>] ? kref_get+0x21/0x30
Mar 17 17:32:27 lotus kernel: [ 7049.333309]  [<c127fbc1>] ? kref_get+0x21/0x30
Mar 17 17:32:27 lotus kernel: [ 7049.337077]  [<c1058ce2>] ? warn_slowpath_null+0x22/0x30
Mar 17 17:32:27 lotus kernel: [ 7049.340879]  [<c127fbc1>] ? kref_get+0x21/0x30
Mar 17 17:32:27 lotus kernel: [ 7049.344648]  [<f863a669>] ? T.557+0x1f9/0x490 [uss720]
Mar 17 17:32:27 lotus kernel: [ 7049.348412]  [<f863ac13>] ? set_1284_register+0x83/0x120 [uss720]
Mar 17 17:32:27 lotus kernel: [ 7049.352215]  [<f863af89>] ? parport_uss720_write_data+0x39/0x80
[uss720]
Mar 17 17:32:27 lotus kernel: [ 7049.356044]  [<f8622ae7>] ? pp_do_ioctl.clone.2+0x4a7/0x7c0 [ppdev]
Mar 17 17:32:27 lotus kernel: [ 7049.359866]  [<c107b9f3>] ? hrtimer_nanosleep+0x93/0x140
Mar 17 17:32:27 lotus kernel: [ 7049.363668]  [<f8622e34>] ? pp_ioctl+0x34/0x50 [ppdev]
Mar 17 17:32:27 lotus kernel: [ 7049.367493]  [<f8622e00>] ? pp_ioctl+0x0/0x50 [ppdev]
Mar 17 17:32:27 lotus kernel: [ 7049.371245]  [<c1141c0b>] ? do_vfs_ioctl+0x7b/0x2e0
Mar 17 17:32:27 lotus kernel: [ 7049.374994]  [<c1141ef7>] ? sys_ioctl+0x87/0x90
Mar 17 17:32:27 lotus kernel: [ 7049.378813]  [<c100ab5f>] ? sysenter_do_call+0x12/0x28
Mar 17 17:32:27 lotus kernel: [ 7049.382447] ---[ end trace c0655632352fda62 ]---

After debugging uss720 driver i discovered that the completion callback was called
before usb_submit_urb returns.

The callback frees the request structure that is krefed on return by usb_submit_urb.


--- uss720.c.orig       2011-03-18 13:17:55.000000000 +0100
+++ uss720.c    2011-03-18 13:37:40.581204665 +0100
@@ -177,12 +177,12 @@
        spin_lock_irqsave(&priv->asynclock, flags);
        list_add_tail(&rq->asynclist, &priv->asynclist);
        spin_unlock_irqrestore(&priv->asynclock, flags);
+       kref_get(&rq->ref_count);
        ret = usb_submit_urb(rq->urb, mem_flags);
        if (!ret) {
-               kref_get(&rq->ref_count);
                return rq;
        }
-       kref_put(&rq->ref_count, destroy_async);
+       destroy_async(&rq->ref_count);
        err("submit_async_request submit_urb failed with %d", ret);
        return NULL;
 }


cu Peter



--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux