mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@elte.hu>
To: Robert Richter <robert.richter@amd.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
	oprofile-list <oprofile-list@lists.sourceforge.net>
Subject: Re: [GIT PULL] oprofile fixes for 3.2
Date: Mon, 19 Dec 2011 15:00:49 +0100	[thread overview]
Message-ID: <20111219140049.GA9097@elte.hu> (raw)
In-Reply-To: <1324302373-30872-1-git-send-email-robert.richter@amd.com>


* Robert Richter <robert.richter@amd.com> wrote:

> Ingo,
> 
> please pull this one fix for 3.2.
> 
> Thanks,
> 
> -Robert
> 
> 
> 
> The following changes since commit dc47ce90c3a822cd7c9e9339fe4d5f61dcb26b50:
> 
>   Linux 3.2-rc5 (2011-12-09 15:09:32 -0800)
> 
> are available in the git repository at:
>   git://git.kernel.org/pub/scm/linux/kernel/git/rric/oprofile.git urgent
> 
> Robert Richter (1):
>       oprofile: Fix uninitialized memory access when writing to oprofilefs
> 
>  arch/s390/oprofile/init.c         |    3 +++
>  drivers/oprofile/oprofile_files.c |    9 +++++++++
>  drivers/oprofile/oprofilefs.c     |   15 ++++++++++++++-
>  3 files changed, 26 insertions(+), 1 deletions(-)

Hm, i really don't like this:

+	if (!count)
+		return 0;
+
 	retval = oprofilefs_ulong_from_user(&val, buf, count);
 	if (retval)
 		return retval;

+	if (!count)
+		return 0;
+
 	retval = oprofilefs_ulong_from_user(&val, buf, count);
 	if (retval)
 		return retval;

+	if (!count)
+		return 0;
+
 	retval = oprofilefs_ulong_from_user(&val, buf, count);
 	if (retval)
 		return retval;
 
+	if (!count)
+		return 0;
+
 	retval = oprofilefs_ulong_from_user(&val, buf, count);
 	if (retval)
 		return retval;

+	if (!count)
+		return 0;
+
 	retval = oprofilefs_ulong_from_user(&value, buf, count);
 	if (retval)
 		return retval;

See the ugly and fragile pattern?

This should *really* be solved via the 
oprofilefs_ulong_from_user() helper function, not by sprinkling 
the !count checks in half a dozen places ...

Thanks,

	Ingo

  parent reply	other threads:[~2011-12-19 14:02 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-19 13:46 Robert Richter
2011-12-19 13:46 ` [PATCH] oprofile: Fix uninitialized memory access when writing to oprofilefs Robert Richter
2011-12-19 14:00 ` Ingo Molnar [this message]
2011-12-19 14:17   ` [GIT PULL] oprofile fixes for 3.2 Robert Richter
2011-12-19 15:38     ` [PATCH v2] oprofile: Fix uninitialized memory access when writing to Robert Richter
2011-12-19 16:19       ` Ingo Molnar
2011-12-20  8:57       ` [tip:perf/urgent] oprofile: Fix uninitialized memory access when writing to writing to oprofilefs tip-bot for Robert Richter
2011-12-22 15:15 ` [PATCH] oprofile, arm/sh: Fix oprofile_arch_exit() linkage issue Robert Richter
2011-12-23 13:19   ` [tip:perf/urgent] " tip-bot for Vladimir Zapolskiy

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=20111219140049.GA9097@elte.hu \
    --to=mingo@elte.hu \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oprofile-list@lists.sourceforge.net \
    --cc=robert.richter@amd.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

Powered by JetHome