public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Oleg Drokin <green@linuxhacker.ru>
To: Denis Vlasenko <vda@port.imtp.ilyichevsk.odessa.ua>
Cc: alan@redhat.com, linux-kernel@vger.kernel.org,
	zubarev@us.ibm.com, gregkh@us.ibm.com
Subject: Re: [2.4] Multiple memleaks in IBM Hot Plug Controller Driver
Date: Fri, 14 Mar 2003 13:26:02 +0300	[thread overview]
Message-ID: <20030314102602.GA7985@linuxhacker.ru> (raw)
In-Reply-To: <200303140957.h2E9vfu08416@Port.imtp.ilyichevsk.odessa.ua>

Hello!

On Fri, Mar 14, 2003 at 11:54:40AM +0200, Denis Vlasenko wrote:

> > +	if (!str)
> > +		return NULL;
> >  	memset (str, 0, 3);
> This was fun, right? "Lets add second memset just in case
> first failed" ;) ;)

Ah, I was half asleep when doing the change, so I missed
other obvious stuff it seems, like memset of three bytes to
two byte variabe :)
memset on wrong thing (second memset should be applied to str1 of course.)

But as Greg KH said already, whis stuff should be replaced by version from 2.5 instead ;)

> >  	bit = (int)(var / 10);
> >  	switch (bit) {
> > @@ -608,13 +608,20 @@
> >  		return str;
> >  	default:
> >  		//2 digits number
> > +		str1 = (char *) kmalloc (2, GFP_KERNEL);
> > +		if (!str1) {
> > +			break;
> > +		}
> > +		memset (str, 0, 3);
> > +             memset (str, 0, 3);
> >               *str1 = (char)(bit + 48);
> >               strncpy (str, str1, 1);
> >               memset (str1, 0, 3);
> Wow! *str1 is 2 bytes long, not 3!

yup.

> Anyway, here is the diff against some old 2.5 (sorry don't have latest
> tree here at the moment). Also here are old and new functions
> for easy visual diff. Completely untested:

New 2.5 code does not have this function at all.
I will look into porting 2.5 changes back to 2.4 tonight. This seems to be proper solution
in this case.

Bye,
    Oleg

      reply	other threads:[~2003-03-14 10:16 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-03-13 20:45 [2.4] Multiple memleaks in IBM Hot Plug Controller Driver Oleg Drokin
2003-03-14  0:31 ` Greg KH
2003-03-14 20:14   ` Oleg Drokin
2003-03-14  8:34 ` Björn Fahller
2003-03-14  8:57   ` Greg KH
2003-03-14  9:54 ` Denis Vlasenko
2003-03-14 10:26   ` Oleg Drokin [this message]

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=20030314102602.GA7985@linuxhacker.ru \
    --to=green@linuxhacker.ru \
    --cc=alan@redhat.com \
    --cc=gregkh@us.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=vda@port.imtp.ilyichevsk.odessa.ua \
    --cc=zubarev@us.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