* [PATCH] staging: r8188eu: Add _enter_critical_mutex() error handling
@ 2015-10-09 22:37 Alexey Khoroshilov
2015-10-10 15:04 ` Dan Carpenter
0 siblings, 1 reply; 3+ messages in thread
From: Alexey Khoroshilov @ 2015-10-09 22:37 UTC (permalink / raw)
To: Greg Kroah-Hartman, Larry Finger
Cc: Alexey Khoroshilov, devel, linux-kernel, ldv-project
_enter_critical_mutex() is a simple call to mutex_lock_interruptible(),
but there is no error handling code for it.
The patch removes wrapper _enter_critical_mutex() and
adds error handling for mutex_lock_interruptible().
Found by Linux Driver Verification project (linuxtesting.org).
Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
---
drivers/staging/rtl8188eu/core/rtw_mlme_ext.c | 5 +++--
drivers/staging/rtl8188eu/include/osdep_service.h | 9 ---------
drivers/staging/rtl8188eu/os_dep/os_intfs.c | 3 ++-
drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c | 5 ++++-
4 files changed, 9 insertions(+), 13 deletions(-)
diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
index 935b48eef8b1..4e9312f0e902 100644
--- a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
+++ b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
@@ -271,7 +271,8 @@ static s32 dump_mgntframe_and_wait_ack(struct adapter *padapter,
if (padapter->bSurpriseRemoved || padapter->bDriverStopped)
return -1;
- _enter_critical_mutex(&pxmitpriv->ack_tx_mutex, NULL);
+ if (!mutex_lock_interruptible(&pxmitpriv->ack_tx_mutex))
+ return _FAIL;
pxmitpriv->ack_tx = true;
pmgntframe->ack_report = 1;
@@ -282,7 +283,7 @@ static s32 dump_mgntframe_and_wait_ack(struct adapter *padapter,
pxmitpriv->ack_tx = false;
mutex_unlock(&pxmitpriv->ack_tx_mutex);
- return ret;
+ return ret;
}
static int update_hidden_ssid(u8 *ies, u32 ies_len, u8 hidden_ssid_mode)
diff --git a/drivers/staging/rtl8188eu/include/osdep_service.h b/drivers/staging/rtl8188eu/include/osdep_service.h
index cf9ca685eb77..96505a6dbe2c 100644
--- a/drivers/staging/rtl8188eu/include/osdep_service.h
+++ b/drivers/staging/rtl8188eu/include/osdep_service.h
@@ -67,15 +67,6 @@ static inline struct list_head *get_list_head(struct __queue *queue)
return &(queue->queue);
}
-static inline int _enter_critical_mutex(struct mutex *pmutex,
- unsigned long *pirqL)
-{
- int ret;
-
- ret = mutex_lock_interruptible(pmutex);
- return ret;
-}
-
static inline int rtw_netif_queue_stopped(struct net_device *pnetdev)
{
return netif_tx_queue_stopped(netdev_get_tx_queue(pnetdev, 0)) &&
diff --git a/drivers/staging/rtl8188eu/os_dep/os_intfs.c b/drivers/staging/rtl8188eu/os_dep/os_intfs.c
index 2361bce480c3..9a3425a7110d 100644
--- a/drivers/staging/rtl8188eu/os_dep/os_intfs.c
+++ b/drivers/staging/rtl8188eu/os_dep/os_intfs.c
@@ -1053,7 +1053,8 @@ static int netdev_open(struct net_device *pnetdev)
int ret;
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(pnetdev);
- _enter_critical_mutex(&padapter->hw_init_mutex, NULL);
+ if (mutex_lock_interruptible(&padapter->hw_init_mutex))
+ return -ERESTARTSYS;
ret = _netdev_open(pnetdev);
mutex_unlock(&padapter->hw_init_mutex);
return ret;
diff --git a/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c b/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c
index 7e599bc5b2d3..0fea338d7313 100644
--- a/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c
+++ b/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c
@@ -249,7 +249,10 @@ static int usbctrl_vendorreq(struct adapter *adapt, u8 request, u16 value, u16 i
goto exit;
}
- _enter_critical_mutex(&dvobjpriv->usb_vendor_req_mutex, NULL);
+ if (mutex_lock_interruptible(&dvobjpriv->usb_vendor_req_mutex)) {
+ status = -ERESTARTSYS;
+ goto exit;
+ }
/* Acquire IO memory for vendorreq */
pIo_buf = dvobjpriv->usb_vendor_req_buf;
--
1.9.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] staging: r8188eu: Add _enter_critical_mutex() error handling
2015-10-09 22:37 [PATCH] staging: r8188eu: Add _enter_critical_mutex() error handling Alexey Khoroshilov
@ 2015-10-10 15:04 ` Dan Carpenter
2015-10-17 21:33 ` [PATCH v2] " Alexey Khoroshilov
0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2015-10-10 15:04 UTC (permalink / raw)
To: Alexey Khoroshilov
Cc: Greg Kroah-Hartman, Larry Finger, devel, ldv-project,
linux-kernel
On Sat, Oct 10, 2015 at 01:37:47AM +0300, Alexey Khoroshilov wrote:
> _enter_critical_mutex() is a simple call to mutex_lock_interruptible(),
> but there is no error handling code for it.
>
> The patch removes wrapper _enter_critical_mutex() and
> adds error handling for mutex_lock_interruptible().
>
> Found by Linux Driver Verification project (linuxtesting.org).
>
> Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
> ---
> drivers/staging/rtl8188eu/core/rtw_mlme_ext.c | 5 +++--
> drivers/staging/rtl8188eu/include/osdep_service.h | 9 ---------
> drivers/staging/rtl8188eu/os_dep/os_intfs.c | 3 ++-
> drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c | 5 ++++-
> 4 files changed, 9 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
> index 935b48eef8b1..4e9312f0e902 100644
> --- a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
> +++ b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
> @@ -271,7 +271,8 @@ static s32 dump_mgntframe_and_wait_ack(struct adapter *padapter,
> if (padapter->bSurpriseRemoved || padapter->bDriverStopped)
> return -1;
>
> - _enter_critical_mutex(&pxmitpriv->ack_tx_mutex, NULL);
> + if (!mutex_lock_interruptible(&pxmitpriv->ack_tx_mutex))
> + return _FAIL;
This is reversed. mutex_lock_interruptible() returns -EINTR on failure.
The rest of this patch is correct.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v2] staging: r8188eu: Add _enter_critical_mutex() error handling
2015-10-10 15:04 ` Dan Carpenter
@ 2015-10-17 21:33 ` Alexey Khoroshilov
0 siblings, 0 replies; 3+ messages in thread
From: Alexey Khoroshilov @ 2015-10-17 21:33 UTC (permalink / raw)
To: Greg Kroah-Hartman, Larry Finger
Cc: Alexey Khoroshilov, Dan Carpenter, devel, linux-kernel,
ldv-project
_enter_critical_mutex() is a simple call to mutex_lock_interruptible(),
but there is no error handling code for it.
The patch removes wrapper _enter_critical_mutex() and
adds error handling for mutex_lock_interruptible().
Found by Linux Driver Verification project (linuxtesting.org).
Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
---
drivers/staging/rtl8188eu/core/rtw_mlme_ext.c | 5 +++--
drivers/staging/rtl8188eu/include/osdep_service.h | 9 ---------
drivers/staging/rtl8188eu/os_dep/os_intfs.c | 3 ++-
drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c | 5 ++++-
4 files changed, 9 insertions(+), 13 deletions(-)
diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
index 935b48eef8b1..4e9312f0e902 100644
--- a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
+++ b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
@@ -271,7 +271,8 @@ static s32 dump_mgntframe_and_wait_ack(struct adapter *padapter,
if (padapter->bSurpriseRemoved || padapter->bDriverStopped)
return -1;
- _enter_critical_mutex(&pxmitpriv->ack_tx_mutex, NULL);
+ if (mutex_lock_interruptible(&pxmitpriv->ack_tx_mutex))
+ return _FAIL;
pxmitpriv->ack_tx = true;
pmgntframe->ack_report = 1;
@@ -282,7 +283,7 @@ static s32 dump_mgntframe_and_wait_ack(struct adapter *padapter,
pxmitpriv->ack_tx = false;
mutex_unlock(&pxmitpriv->ack_tx_mutex);
- return ret;
+ return ret;
}
static int update_hidden_ssid(u8 *ies, u32 ies_len, u8 hidden_ssid_mode)
diff --git a/drivers/staging/rtl8188eu/include/osdep_service.h b/drivers/staging/rtl8188eu/include/osdep_service.h
index cf9ca685eb77..96505a6dbe2c 100644
--- a/drivers/staging/rtl8188eu/include/osdep_service.h
+++ b/drivers/staging/rtl8188eu/include/osdep_service.h
@@ -67,15 +67,6 @@ static inline struct list_head *get_list_head(struct __queue *queue)
return &(queue->queue);
}
-static inline int _enter_critical_mutex(struct mutex *pmutex,
- unsigned long *pirqL)
-{
- int ret;
-
- ret = mutex_lock_interruptible(pmutex);
- return ret;
-}
-
static inline int rtw_netif_queue_stopped(struct net_device *pnetdev)
{
return netif_tx_queue_stopped(netdev_get_tx_queue(pnetdev, 0)) &&
diff --git a/drivers/staging/rtl8188eu/os_dep/os_intfs.c b/drivers/staging/rtl8188eu/os_dep/os_intfs.c
index 2361bce480c3..9a3425a7110d 100644
--- a/drivers/staging/rtl8188eu/os_dep/os_intfs.c
+++ b/drivers/staging/rtl8188eu/os_dep/os_intfs.c
@@ -1053,7 +1053,8 @@ static int netdev_open(struct net_device *pnetdev)
int ret;
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(pnetdev);
- _enter_critical_mutex(&padapter->hw_init_mutex, NULL);
+ if (mutex_lock_interruptible(&padapter->hw_init_mutex))
+ return -ERESTARTSYS;
ret = _netdev_open(pnetdev);
mutex_unlock(&padapter->hw_init_mutex);
return ret;
diff --git a/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c b/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c
index 7e599bc5b2d3..0fea338d7313 100644
--- a/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c
+++ b/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c
@@ -249,7 +249,10 @@ static int usbctrl_vendorreq(struct adapter *adapt, u8 request, u16 value, u16 i
goto exit;
}
- _enter_critical_mutex(&dvobjpriv->usb_vendor_req_mutex, NULL);
+ if (mutex_lock_interruptible(&dvobjpriv->usb_vendor_req_mutex)) {
+ status = -ERESTARTSYS;
+ goto exit;
+ }
/* Acquire IO memory for vendorreq */
pIo_buf = dvobjpriv->usb_vendor_req_buf;
--
1.9.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-10-17 21:33 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-09 22:37 [PATCH] staging: r8188eu: Add _enter_critical_mutex() error handling Alexey Khoroshilov
2015-10-10 15:04 ` Dan Carpenter
2015-10-17 21:33 ` [PATCH v2] " Alexey Khoroshilov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox