public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: Rolf Eike Beer <eike-kernel@sf-tec.de>
To: "Moger, Babu" <Babu.Moger@lsi.com>
Cc: Hillf Danton <dhillf@gmail.com>,
	"linux-scsi@vger.kernel.org" <linux-scsi@vger.kernel.org>,
	Chandra Seetharaman <chandra.seetharaman@us.ibm.com>
Subject: Re: [PATCH] fix kzalloc in scsi device handler
Date: Tue, 16 Nov 2010 20:17:43 +0100	[thread overview]
Message-ID: <201011162017.44328.eike-kernel@sf-tec.de> (raw)
In-Reply-To: <E463DF2B2E584B4A82673F53D62C2EF4F51A7FEA@cosmail01.lsi.com>

[-- Attachment #1: Type: Text/Plain, Size: 2484 bytes --]

Moger, Babu wrote:
> > -----Original Message-----
> > From: Rolf Eike Beer [mailto:eike-kernel@sf-tec.de]
> > Sent: Tuesday, November 16, 2010 11:36 AM
> > To: Moger, Babu
> > Cc: Hillf Danton; linux-scsi@vger.kernel.org; Chandra Seetharaman
> > Subject: Re: [PATCH] fix kzalloc in scsi device handler
> > 
> > Moger, Babu wrote:
> > > Agree.. But this may not fix the problem completely.. Please see my
> > > comments below.. Also copied Chandra if he has any comments..
> > > 
> > > > -----Original Message-----
> > > > From: linux-scsi-owner@vger.kernel.org [mailto:linux-scsi-
> > > > owner@vger.kernel.org] On Behalf Of Hillf Danton
> > > > Sent: Tuesday, November 16, 2010 7:34 AM
> > > > To: linux-scsi@vger.kernel.org
> > > > Subject: [PATCH] fix kzalloc in scsi device handler
> > > > 
> > > > They look like typo, since there are four instances of kzalloc
> > 
> > almost
> > 
> > > > typed by the same finger.
> > > > 
> > > > The pointer is replaced with a struct, which helps kzalloc return
> > > > correct result.
> > > > 
> > > > thanks for any comment on the possibility that mem overflow could
> > > > happen.
> > > > 
> > > > Signed-off-by: Hillf Danton <dhillf@gmail.com>
> > > > ---
> > > > 
> > > > --- a/drivers/scsi/device_handler/scsi_dh_alua.c	2010-11-01
> > > > 19:54:12.000000000 +0800
> > > > +++ b/drivers/scsi/device_handler/scsi_dh_alua.c	2010-11-16
> > > > 20:40:36.000000000 +0800
> > > > @@ -759,7 +759,7 @@ static int alua_bus_attach(struct scsi_d
> > > > 
> > > >  	unsigned long flags;
> > > >  	int err = SCSI_DH_OK;
> > > > 
> > > > -	scsi_dh_data = kzalloc(sizeof(struct scsi_device_handler *)
> > > > +	scsi_dh_data = kzalloc(sizeof(struct scsi_dh_data)
> > > > 
> > > >  			       + sizeof(*h) , GFP_KERNEL);
> > > 
> > > I think this should be like this below.
> > > 
> > >       scsi_dh_data = kzalloc(sizeof(struct scsi_dh_data)
> > >       
> > >   			       + sizeof(struct alua_dh_data) , GFP_KERNEL);
> > 
> > How about kzalloc(sizeof(*scsi_dh_data) + sizeof(*h), GFP_KERNEL)?
> 
> No.. This would only allocate couple of pointers..  The below should be
> good enough..

No, it would not.

>      scsi_dh_data = kzalloc(sizeof(struct scsi_dh_data)
>    			       + sizeof(struct alua_dh_data) , GFP_KERNEL);

And that is exactly what I tried to avoid. Look at the * before the variable 
name. That would allocate the space for what that pointer is pointing to.

Eike

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

  reply	other threads:[~2010-11-16 19:17 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-16 13:34 [PATCH] fix kzalloc in scsi device handler Hillf Danton
2010-11-16 16:15 ` Moger, Babu
2010-11-16 17:35   ` Rolf Eike Beer
2010-11-16 18:57     ` Moger, Babu
2010-11-16 19:17       ` Rolf Eike Beer [this message]
2010-11-16 19:23         ` Moger, Babu
2010-11-17 10:04     ` Boaz Harrosh
2010-11-17 13:16       ` Hillf Danton

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=201011162017.44328.eike-kernel@sf-tec.de \
    --to=eike-kernel@sf-tec.de \
    --cc=Babu.Moger@lsi.com \
    --cc=chandra.seetharaman@us.ibm.com \
    --cc=dhillf@gmail.com \
    --cc=linux-scsi@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