The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Ameer Hamza <amhamza.mgc@gmail.com>
To: gregkh@linuxfoundation.org, arve@android.com, tkjos@android.com,
	maco@android.com, joel@joelfernandes.org, christian@brauner.io,
	hridya@google.com, surenb@google.com
Cc: linux-kernel@vger.kernel.org, amhamza.mgc@gmail.com
Subject: [PATCH] binder: fixed coverity warning by moving pr_warn outside lock
Date: Sat,  4 Dec 2021 01:50:41 +0500	[thread overview]
Message-ID: <20211203205041.115331-1-amhamza.mgc@gmail.com> (raw)

Coverity warns about using print operations within a lock due to
unlikely possible deadlock scenario, however, this warning can be
easily avoided here without having any effect on the program flow.

Addresses-Coverity: 1494148 ("Thread deadlock")

Signed-off-by: Ameer Hamza <amhamza.mgc@gmail.com>
---
 drivers/android/binder.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/android/binder.c b/drivers/android/binder.c
index cffbe57a8e08..8ee942eef51d 100644
--- a/drivers/android/binder.c
+++ b/drivers/android/binder.c
@@ -1507,14 +1507,14 @@ static void binder_free_transaction(struct binder_transaction *t)
 	if (target_proc) {
 		binder_inner_proc_lock(target_proc);
 		target_proc->outstanding_txns--;
-		if (target_proc->outstanding_txns < 0)
-			pr_warn("%s: Unexpected outstanding_txns %d\n",
-				__func__, target_proc->outstanding_txns);
 		if (!target_proc->outstanding_txns && target_proc->is_frozen)
 			wake_up_interruptible_all(&target_proc->freeze_wait);
 		if (t->buffer)
 			t->buffer->transaction = NULL;
 		binder_inner_proc_unlock(target_proc);
+		if (target_proc->outstanding_txns < 0)
+			pr_warn("%s: Unexpected outstanding_txns %d\n",
+				__func__, target_proc->outstanding_txns);
 	}
 	if (trace_binder_txn_latency_free_enabled())
 		binder_txn_latency_free(t);
-- 
2.25.1


             reply	other threads:[~2021-12-03 20:51 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-03 20:50 Ameer Hamza [this message]
2021-12-04  7:57 ` [PATCH] binder: fixed coverity warning by moving pr_warn outside lock Greg KH
     [not found]   ` <CANAWnNyyBR3EEtT=SecqGQsc+tnJi6GiqrW0xkqRn5jrV7CpDA@mail.gmail.com>
2021-12-04  9:00     ` Greg KH
2021-12-04 10:34       ` Ameer Hamza
2021-12-04 10:42         ` Greg KH

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=20211203205041.115331-1-amhamza.mgc@gmail.com \
    --to=amhamza.mgc@gmail.com \
    --cc=arve@android.com \
    --cc=christian@brauner.io \
    --cc=gregkh@linuxfoundation.org \
    --cc=hridya@google.com \
    --cc=joel@joelfernandes.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maco@android.com \
    --cc=surenb@google.com \
    --cc=tkjos@android.com \
    /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