Skip to content

Commit adaa3c6

Browse files
PeterHolikgregkh
authored andcommitted
USB: uss720 fixup refcount position
My testprog do a lot of bitbang - after hours i got following warning and my machine lockups: WARNING: at /build/buildd/linux-2.6.38/lib/kref.c:34 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. Signed-off-by: Peter Holik <peter@holik.at> Acked-by: Thomas Sailer <t.sailer@alumni.ethz.ch> Cc: stable <stable@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
1 parent 45567c2 commit adaa3c6

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

‎drivers/usb/misc/uss720.c‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,12 +177,11 @@ static struct uss720_async_request *submit_async_request(struct parport_uss720_p
177177
spin_lock_irqsave(&priv->asynclock, flags);
178178
list_add_tail(&rq->asynclist, &priv->asynclist);
179179
spin_unlock_irqrestore(&priv->asynclock, flags);
180+
kref_get(&rq->ref_count);
180181
ret = usb_submit_urb(rq->urb, mem_flags);
181-
if (!ret) {
182-
kref_get(&rq->ref_count);
182+
if (!ret)
183183
return rq;
184-
}
185-
kref_put(&rq->ref_count, destroy_async);
184+
destroy_async(&rq->ref_count);
186185
err("submit_async_request submit_urb failed with %d", ret);
187186
return NULL;
188187
}

0 commit comments

Comments
 (0)