public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Chen Gang <gang.chen@asianux.com>
To: bsingharora@gmail.com
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: [PATCH] kernel/delayacct.c: check NULL for member variable 'delays' in all extern functions.
Date: Tue, 20 Aug 2013 10:40:03 +0800	[thread overview]
Message-ID: <5212D703.5080405@asianux.com> (raw)

The member variable 'delays' may be NULL, so need check NULL before use
it for all extern functions, just like __delayacct_tsk_init() and
__delayacct_add_tsk() have already done.


Signed-off-by: Chen Gang <gang.chen@asianux.com>
---
 kernel/delayacct.c |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/kernel/delayacct.c b/kernel/delayacct.c
index d473988..10cddce 100644
--- a/kernel/delayacct.c
+++ b/kernel/delayacct.c
@@ -81,11 +81,15 @@ static void delayacct_end(struct timespec *start, struct timespec *end,
 
 void __delayacct_blkio_start(void)
 {
+	if (!current->delays)
+		return;
 	delayacct_start(&current->delays->blkio_start);
 }
 
 void __delayacct_blkio_end(void)
 {
+	if (!current->delays)
+		return;
 	if (current->delays->flags & DELAYACCT_PF_SWAPIN)
 		/* Swapin block I/O */
 		delayacct_end(&current->delays->blkio_start,
@@ -167,6 +171,8 @@ __u64 __delayacct_blkio_ticks(struct task_struct *tsk)
 	__u64 ret;
 	unsigned long flags;
 
+	if (!tsk->delays)
+		return 0;
 	spin_lock_irqsave(&tsk->delays->lock, flags);
 	ret = nsec_to_clock_t(tsk->delays->blkio_delay +
 				tsk->delays->swapin_delay);
@@ -176,11 +182,15 @@ __u64 __delayacct_blkio_ticks(struct task_struct *tsk)
 
 void __delayacct_freepages_start(void)
 {
+	if (!current->delays)
+		return;
 	delayacct_start(&current->delays->freepages_start);
 }
 
 void __delayacct_freepages_end(void)
 {
+	if (!current->delays)
+		return;
 	delayacct_end(&current->delays->freepages_start,
 			&current->delays->freepages_end,
 			&current->delays->freepages_delay,
-- 
1.7.7.6

             reply	other threads:[~2013-08-20  2:41 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-20  2:40 Chen Gang [this message]
2013-08-20  2:44 ` [PATCH] kernel/taskstats.c: add nla_nest_cancel() for failure processing between nla_nest_start() and nla_nest_end() Chen Gang
2013-09-03  5:07   ` Chen Gang
2013-08-21 22:10 ` [PATCH] kernel/delayacct.c: check NULL for member variable 'delays' in all extern functions Andrew Morton
2013-08-22  2:17   ` Chen Gang
2013-09-03  5:03     ` [PATCH] kernel/delayacct.c: remove redundancy checking in __delayacct_add_tsk() Chen Gang

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=5212D703.5080405@asianux.com \
    --to=gang.chen@asianux.com \
    --cc=bsingharora@gmail.com \
    --cc=linux-kernel@vger.kernel.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