mirror of
https://github.com/SCST-project/scst.git
synced 2026-05-17 18:51:27 +00:00
scst_targ: Check prepare_to_wait_exclusive_head() return value
The prepare_to_wait_exclusive_head() function was modified in
commit d8894cbd11 ("scst.h: Refactor wait_event_locked() to enhance
usability and clarity"). It now returns an error if the current
interruptible thread has pending signals.
This patch introduces the scst_wait_for_cmd() helper function for the
scst_cmd_thread(). This new function handles the return value of the
prepare_to_wait_exclusive_head() appropriately.
This patch fixes the following Coverity complaint:
CID 321410 (#1 of 1): Unchecked return value (CHECKED_RETURN)
check_return: Calling prepare_to_wait_exclusive_head without
checking return value.
This commit is contained in:
@@ -4800,6 +4800,39 @@ static inline int test_cmd_threads(struct scst_cmd_thread_t *thr)
|
||||
return res;
|
||||
}
|
||||
|
||||
static inline int
|
||||
scst_wait_for_cmd(struct scst_cmd_threads *p_cmd_threads, struct scst_cmd_thread_t *thr)
|
||||
{
|
||||
DEFINE_WAIT(wq_entry);
|
||||
int ret = 0;
|
||||
|
||||
if (test_cmd_threads(thr))
|
||||
return 0;
|
||||
|
||||
for (;;) {
|
||||
long __int = prepare_to_wait_exclusive_head(&p_cmd_threads->cmd_list_waitQ,
|
||||
&wq_entry, TASK_INTERRUPTIBLE);
|
||||
|
||||
if (test_cmd_threads(thr))
|
||||
break;
|
||||
|
||||
if (__int) {
|
||||
ret = __int;
|
||||
goto out;
|
||||
}
|
||||
|
||||
spin_unlock(&thr->thr_cmd_list_lock);
|
||||
spin_unlock_irq(&p_cmd_threads->cmd_list_lock);
|
||||
schedule();
|
||||
spin_lock_irq(&p_cmd_threads->cmd_list_lock);
|
||||
spin_lock(&thr->thr_cmd_list_lock);
|
||||
}
|
||||
finish_wait(&p_cmd_threads->cmd_list_waitQ, &wq_entry);
|
||||
|
||||
out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
int scst_cmd_thread(void *arg)
|
||||
{
|
||||
struct scst_cmd_thread_t *thr = arg;
|
||||
@@ -4822,23 +4855,7 @@ int scst_cmd_thread(void *arg)
|
||||
spin_lock_irq(&p_cmd_threads->cmd_list_lock);
|
||||
spin_lock(&thr->thr_cmd_list_lock);
|
||||
while (!kthread_should_stop()) {
|
||||
if (!test_cmd_threads(thr)) {
|
||||
DEFINE_WAIT(wait);
|
||||
|
||||
do {
|
||||
prepare_to_wait_exclusive_head(
|
||||
&p_cmd_threads->cmd_list_waitQ,
|
||||
&wait, TASK_INTERRUPTIBLE);
|
||||
if (test_cmd_threads(thr))
|
||||
break;
|
||||
spin_unlock(&thr->thr_cmd_list_lock);
|
||||
spin_unlock_irq(&p_cmd_threads->cmd_list_lock);
|
||||
schedule();
|
||||
spin_lock_irq(&p_cmd_threads->cmd_list_lock);
|
||||
spin_lock(&thr->thr_cmd_list_lock);
|
||||
} while (!test_cmd_threads(thr));
|
||||
finish_wait(&p_cmd_threads->cmd_list_waitQ, &wait);
|
||||
}
|
||||
scst_wait_for_cmd(p_cmd_threads, thr);
|
||||
|
||||
if (tm_dbg_is_release()) {
|
||||
spin_unlock_irq(&p_cmd_threads->cmd_list_lock);
|
||||
|
||||
Reference in New Issue
Block a user