USB: serial: mos7720: fix mos_parport refcount imbalance on error path
Subsystems (2)
PATCH v2 1/1 USB: serial: mos7720: fix mos_parport refcount imbalance on error path
Johan said that move the kref_get() and mos_parport assignment to the end of urbtrack initialisation is a better way, so move it. and mos_parport do not used until urbtrack initialisation.
Signed-off-by Lin Yi <[email protected]>
--- drivers/usb/serial/mos7720.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/usb/serial/mos7720.c +2 -2
@@ -366,8 +366,6 @@ static int write_parport_reg_nonblock(struct mos7715_parport *mos_parport,if (!urbtrack)return -ENOMEM ; -kref_get (&mos_parport->ref_count); - urbtrack->mos_parport = mos_parport; urbtrack->urb =usb_alloc_urb (0 ,GFP_ATOMIC );if (!urbtrack->urb) {kfree (urbtrack);
@@ -388,6 +386,8 @@ static int write_parport_reg_nonblock(struct mos7715_parport *mos_parport,usb_sndctrlpipe (usbdev,0 ), (unsigned char *)urbtrack->setup, NULL, 0, async_complete, urbtrack); +kref_get (&mos_parport->ref_count); + urbtrack->mos_parport = mos_parport;kref_init (&urbtrack->ref_count);INIT_LIST_HEAD (&urbtrack->urblist_entry);