[PATCH] drivers/usb/host/ohci* : set urb->hcpriv = NULL immediately, after free it

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

 



  although we can not say it is surely a bug.
  it is better to set urb->hcpriv = NULL, after finish calling urb_free_priv.
  before kfree urb_priv, better to judge whether urb_priv == NULL, firstly.

Signed-off-by: Chen Gang <gang.chen@xxxxxxxxxxx>
---
 drivers/usb/host/ohci-q.c |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/host/ohci-q.c b/drivers/usb/host/ohci-q.c
index 7482cfb..6671107 100644
--- a/drivers/usb/host/ohci-q.c
+++ b/drivers/usb/host/ohci-q.c
@@ -12,8 +12,12 @@
 
 static void urb_free_priv (struct ohci_hcd *hc, urb_priv_t *urb_priv)
 {
-	int		last = urb_priv->length - 1;
+	int		last;
 
+	if (!urb_priv)
+		return;
+
+	last = urb_priv->length - 1;
 	if (last >= 0) {
 		int		i;
 		struct td	*td;
@@ -44,6 +48,7 @@ __acquires(ohci->lock)
 	// ASSERT (urb->hcpriv != 0);
 
 	urb_free_priv (ohci, urb->hcpriv);
+	urb->hcpriv = NULL;
 	if (likely(status == -EINPROGRESS))
 		status = 0;
 
-- 
1.7.10.4
--
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