mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Yuan Pengfei" <coolypf@qq.com>
To: "Peter Oberparleiter" <oberpar@linux.vnet.ibm.com>
Cc: linux-kernel <linux-kernel@vger.kernel.org>
Subject: [PATCH] gcov: fix memory allocation problem in gcov_info_dup
Date: Wed, 19 Feb 2014 15:06:15 +0800	[thread overview]
Message-ID: <tencent_074552B42B4D25D2329613D8@qq.com> (raw)

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="utf-8", Size: 1408 bytes --]

From: Yuan Pengfei <coolypf@qq.com>

If -fprofile-values option is used, ctr->num and sci_ptr->num
may be zero, resulting in zero size and cv_size, which will
cause ENOMEM when opening gcov data files in debugfs.
Signed-off-by: Yuan Pengfei <coolypf@qq.com>
---
 kernel/gcov/gcc_3_4.c | 2 +-
 kernel/gcov/gcc_4_7.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/gcov/gcc_3_4.c b/kernel/gcov/gcc_3_4.c
index 27bc88a..1c1f425 100644
--- a/kernel/gcov/gcc_3_4.c
+++ b/kernel/gcov/gcc_3_4.c
@@ -269,7 +269,7 @@ struct gcov_info *gcov_info_dup(struct gcov_info *info)
 		dup->counts[i].num = ctr->num;
 		dup->counts[i].merge = ctr->merge;
 		dup->counts[i].values = vmalloc(size);
-		if (!dup->counts[i].values)
+		if (size && !dup->counts[i].values)
 			goto err_free;
 		memcpy(dup->counts[i].values, ctr->values, size);
 	}
diff --git a/kernel/gcov/gcc_4_7.c b/kernel/gcov/gcc_4_7.c
index 2c6e463..7465944 100644
--- a/kernel/gcov/gcc_4_7.c
+++ b/kernel/gcov/gcc_4_7.c
@@ -290,7 +290,7 @@ struct gcov_info *gcov_info_dup(struct gcov_info *info)
 
 			dci_ptr->values = vmalloc(cv_size);
 
-			if (!dci_ptr->values)
+			if (cv_size && !dci_ptr->values)
 				goto err_free;
 
 			dci_ptr->num = sci_ptr->num;
-- 
1.8.5.3ÿôèº{.nÇ+‰·Ÿ®‰­†+%ŠËÿ±éݶ\x17¥Šwÿº{.nÇ+‰·¥Š{±þG«éÿŠ{ayº\x1dʇڙë,j\a­¢f£¢·hšïêÿ‘êçz_è®\x03(­éšŽŠÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?™¨è­Ú&£ø§~á¶iO•æ¬z·švØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?–I¥

             reply	other threads:[~2014-02-19  7:14 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-19  7:06 Yuan Pengfei [this message]
2014-02-19  8:52 ` Peter Oberparleiter
2014-02-19 10:38   ` Yuan Pengfei
2014-02-20  8:52     ` Peter Oberparleiter

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=tencent_074552B42B4D25D2329613D8@qq.com \
    --to=coolypf@qq.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oberpar@linux.vnet.ibm.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

all inboxes | Powered by JetHome®