Skip to contentSkip to conversation

fix 2.5 scsi queue depth setting]

PATCH In review Christoph Hellwig 2 participants 3 messages Nov 6, 2002 – Nov 7, 2002 SCSI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fix 2.5 scsi queue depth setting]

Urgg, removed abit to much than just me from the cc line..

----- Forwarded message from Christoph Hellwig <[email protected]> -----

Date: Wed, 6 Nov 2002 21:01:13 +0000
From: Christoph Hellwig <[email protected]>
Subject: Re: [PATCH] fix 2.5 scsi queue depth setting
To: Patrick Mansfield <[email protected]>,
James Bottomley <[email protected]>, [email protected]

Quoted 2 lines · Doug Ledford

if(sdev->hostdata)
kfree(sdev->hostdata);

kfree(NULL) is fine, btw..

Quoted 7 lines

sdev->hostdata = NULL;

after the slave_detach call. The other option is to slightly refine the slave_attach/slave_detach API to specificy that if your attach routine allocates and hangs memory off of sdev->hostdata, then you *must* implement a slave_detach() routine and you must free said memory yourself (and NULL out the pointer to be safe).

I'm all for the second option, but I don't think we should specify the NULLing out, the device will go away anyway.

----- End forwarded message -----

#1 lore raw
Quoted 5 lines · Christoph Hellwig
Quoted 2 lines · Doug Ledford

if(sdev->hostdata)
kfree(sdev->hostdata);

kfree(NULL) is fine, btw..

Yeah, but the existence of a non-NULL pointer can also be used to protect against other possible bogus operations (in the case of my driver it isn't needed, but I wouldn't begin to assume no other driver would) in the event that slave_detach() is ever called twice.

Quoted 10 lines
Quoted 7 lines

sdev->hostdata = NULL;

after the slave_detach call. The other option is to slightly refine the slave_attach/slave_detach API to specificy that if your attach routine allocates and hangs memory off of sdev->hostdata, then you *must* implement a slave_detach() routine and you must free said memory yourself (and NULL out the pointer to be safe).

I'm all for the second option, but I don't think we should specify the NULLing out, the device will go away anyway.

Hmmm...I thought this was being done on upper level de-attachment, which doesn't always imply device removal. I'm not sure the device is going away in all cases....

Signature · 4 lines
  Doug Ledford <[email protected]>     919-754-3700 x44233
         Red Hat, Inc. 
         1801 Varsity Dr.
         Raleigh, NC 27606
#2 lore raw
Quoted 6 lines · Doug Ledford
Quoted 2 lines

I'm all for the second option, but I don't think we should specify the NULLing out, the device will go away anyway.

Hmmm...I thought this was being done on upper level de-attachment, which doesn't always imply device removal. I'm not sure the device is going away in all cases....

In this context it implies that the last upperlayer user of the device goes away and thus the device can't be access from the upperlayer anymore. If a new driver attaches we'll call slave_attach again after Patrick's changes.