public inbox for linux-mmc@vger.kernel.org
 help / color / mirror / Atom feed
From: <rogerable@realtek.com>
To: Samuel Ortiz <sameo@linux.intel.com>,
	Lee Jones <lee.jones@linaro.org>, Chris Ball <chris@printf.net>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Maxim Levitsky <maximlevitsky@gmail.com>,
	Alex Dubov <oakad@yahoo.com>,
	Dan Carpenter <dan.carpenter@oracle.com>,
	Ulf Hansson <ulf.hansson@linaro.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Oliver Neukum <oneukum@suse.de>
Cc: driverdev-devel@linuxdriverproject.org,
	linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org,
	wei_wang@realsil.com.cn, rogerable@realtek.com
Subject: [PATCH v7 1/4] [v6 fix] mfd/rtsx_usb: fix possible race condition
Date: Fri, 11 Apr 2014 14:53:20 +0800	[thread overview]
Message-ID: <1397199203-2235-2-git-send-email-rogerable@realtek.com> (raw)
In-Reply-To: <1397199203-2235-1-git-send-email-rogerable@realtek.com>

From: Roger Tseng <rogerable@realtek.com>

Fix two possible race condition generated by misuse of del_timer in
rtsx_usb_bulk_transfer_sglist() and uninitialized timers before mfd_add_devices
in rtsx_usb_probe().

Signed-off-by: Roger Tseng <rogerable@realtek.com>
---
 drivers/mfd/rtsx_usb.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/mfd/rtsx_usb.c b/drivers/mfd/rtsx_usb.c
index b53b9d4..0ca7973 100644
--- a/drivers/mfd/rtsx_usb.c
+++ b/drivers/mfd/rtsx_usb.c
@@ -67,7 +67,7 @@ static int rtsx_usb_bulk_transfer_sglist(struct rtsx_ucr *ucr,
 	ucr->sg_timer.expires = jiffies + msecs_to_jiffies(timeout);
 	add_timer(&ucr->sg_timer);
 	usb_sg_wait(&ucr->current_sg);
-	del_timer(&ucr->sg_timer);
+	del_timer_sync(&ucr->sg_timer);
 
 	if (act_len)
 		*act_len = ucr->current_sg.bytes;
@@ -644,14 +644,14 @@ static int rtsx_usb_probe(struct usb_interface *intf,
 	if (ret)
 		goto out_init_fail;
 
+	/* initialize USB SG transfer timer */
+	setup_timer(&ucr->sg_timer, rtsx_usb_sg_timed_out, (unsigned long) ucr);
+
 	ret = mfd_add_devices(&intf->dev, usb_dev->devnum, rtsx_usb_cells,
 			ARRAY_SIZE(rtsx_usb_cells), NULL, 0, NULL);
 	if (ret)
 		goto out_init_fail;
 
-	/* initialize USB SG transfer timer */
-	init_timer(&ucr->sg_timer);
-	setup_timer(&ucr->sg_timer, rtsx_usb_sg_timed_out, (unsigned long) ucr);
 #ifdef CONFIG_PM
 	intf->needs_remote_wakeup = 1;
 	usb_enable_autosuspend(usb_dev);
-- 
1.8.2

  reply	other threads:[~2014-04-11  6:53 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-11  6:53 [PATCH v7 0/4] Add modules for realtek USB card reader rogerable
2014-04-11  6:53 ` rogerable [this message]
2014-04-16 10:39   ` [PATCH v7 1/4] [v6 fix] mfd/rtsx_usb: fix possible race condition Lee Jones
2014-04-11  6:53 ` [PATCH v7 2/4] [v6 fix] mfd/rtsx_usb: add comment in rtsx_usb_suspend rogerable
2014-04-16 10:40   ` Lee Jones
2014-04-11  6:53 ` [PATCH v7 3/4] mmc: Add realtek USB sdmmc host driver rogerable
2014-04-28 10:10   ` Lee Jones
2014-04-11  6:53 ` [PATCH v7 4/4] memstick: Add realtek USB memstick " rogerable
2014-04-16  8:13   ` Lee Jones
2014-04-25  7:06     ` Roger
2014-04-25  9:52     ` Dan Carpenter
2014-04-28 10:10   ` Lee Jones
2014-04-30  7:56     ` Roger
2014-05-23 11:47       ` Greg Kroah-Hartman
2014-04-11  7:31 ` [PATCH v7 0/4] Add modules for realtek USB card reader Oliver Neukum
2014-04-11 10:28   ` Lee Jones
2014-04-11 10:36     ` Oliver Neukum
2014-04-16  3:19       ` Roger
2014-04-16  7:27         ` Ulf Hansson
2014-04-16  8:09         ` Lee Jones

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1397199203-2235-2-git-send-email-rogerable@realtek.com \
    --to=rogerable@realtek.com \
    --cc=akpm@linux-foundation.org \
    --cc=chris@printf.net \
    --cc=dan.carpenter@oracle.com \
    --cc=driverdev-devel@linuxdriverproject.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=lee.jones@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=maximlevitsky@gmail.com \
    --cc=oakad@yahoo.com \
    --cc=oneukum@suse.de \
    --cc=sameo@linux.intel.com \
    --cc=ulf.hansson@linaro.org \
    --cc=wei_wang@realsil.com.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox