linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Chintan Pandya <cpandya@codeaurora.org>
To: akpm@linux-foundation.org
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	Chintan Pandya <cpandya@codeaurora.org>
Subject: [PATCH] mm: BUG when __kmap_atomic_idx crosses boundary
Date: Wed, 30 Jul 2014 14:22:35 +0530	[thread overview]
Message-ID: <1406710355-4360-1-git-send-email-cpandya@codeaurora.org> (raw)

__kmap_atomic_idx >= KM_TYPE_NR or < ZERO is a bug.
Report it even if CONFIG_DEBUG_HIGHMEM is not enabled.
That saves much debugging efforts.

Signed-off-by: Chintan Pandya <cpandya@codeaurora.org>
---
 include/linux/highmem.h | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/include/linux/highmem.h b/include/linux/highmem.h
index 7fb31da..f42cafd 100644
--- a/include/linux/highmem.h
+++ b/include/linux/highmem.h
@@ -93,8 +93,8 @@ static inline int kmap_atomic_idx_push(void)
 
 #ifdef CONFIG_DEBUG_HIGHMEM
 	WARN_ON_ONCE(in_irq() && !irqs_disabled());
-	BUG_ON(idx > KM_TYPE_NR);
 #endif
+	BUG_ON(idx >= KM_TYPE_NR);
 	return idx;
 }
 
@@ -105,13 +105,9 @@ static inline int kmap_atomic_idx(void)
 
 static inline void kmap_atomic_idx_pop(void)
 {
-#ifdef CONFIG_DEBUG_HIGHMEM
 	int idx = __this_cpu_dec_return(__kmap_atomic_idx);
 
 	BUG_ON(idx < 0);
-#else
-	__this_cpu_dec(__kmap_atomic_idx);
-#endif
 }
 
 #endif
-- 
Chintan Pandya

QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a
member of the Code Aurora Forum, hosted by The Linux Foundation

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

             reply	other threads:[~2014-07-30  8:52 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-30  8:52 Chintan Pandya [this message]
2014-07-30  9:06 ` [PATCH] mm: BUG when __kmap_atomic_idx crosses boundary Andrew Morton
2014-07-30 10:37   ` Davidlohr Bueso
2014-07-30 10:52     ` Davidlohr Bueso
2014-07-31  5:36   ` Chintan Pandya

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=1406710355-4360-1-git-send-email-cpandya@codeaurora.org \
    --to=cpandya@codeaurora.org \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    /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;
as well as URLs for NNTP newsgroup(s).