diff mbox

[02/12] SQUASHME: Bug in new global-device-cache code

Message ID 1306249480-23212-1-git-send-email-bharrosh@panasas.com (mailing list archive)
State New, archived
Headers show

Commit Message

Boaz Harrosh May 24, 2011, 3:04 p.m. UTC
NULL deref on first ever call. (When device is not found)

Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
---
 fs/nfs/pnfs_dev.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

Comments

Benny Halevy May 24, 2011, 4:52 p.m. UTC | #1
On 2011-05-24 18:04, Boaz Harrosh wrote:
> NULL deref on first ever call. (When device is not found)
> 
> Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
> ---
>  fs/nfs/pnfs_dev.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/fs/nfs/pnfs_dev.c b/fs/nfs/pnfs_dev.c
> index 7997899..7e5542c 100644
> --- a/fs/nfs/pnfs_dev.c
> +++ b/fs/nfs/pnfs_dev.c
> @@ -100,7 +100,7 @@ _find_get_deviceid(const struct pnfs_layoutdriver_type *ld,
>  
>  	rcu_read_lock();
>  	d = _lookup_deviceid(ld, clp, id, hash);
> -	if (!atomic_inc_not_zero(&d->ref))
> +	if (!d || !atomic_inc_not_zero(&d->ref))

This makes more sense, no?
+	if (d && !atomic_inc_not_zero(&d->ref))

Benny

>  		d = NULL;
>  	rcu_read_unlock();
>  	return d;

--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Boaz Harrosh May 24, 2011, 5 p.m. UTC | #2
On 05/24/2011 07:52 PM, Benny Halevy wrote:
> On 2011-05-24 18:04, Boaz Harrosh wrote:
>> NULL deref on first ever call. (When device is not found)
>>
>> Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
>> ---
>>  fs/nfs/pnfs_dev.c |    2 +-
>>  1 files changed, 1 insertions(+), 1 deletions(-)
>>
>> diff --git a/fs/nfs/pnfs_dev.c b/fs/nfs/pnfs_dev.c
>> index 7997899..7e5542c 100644
>> --- a/fs/nfs/pnfs_dev.c
>> +++ b/fs/nfs/pnfs_dev.c
>> @@ -100,7 +100,7 @@ _find_get_deviceid(const struct pnfs_layoutdriver_type *ld,
>>  
>>  	rcu_read_lock();
>>  	d = _lookup_deviceid(ld, clp, id, hash);
>> -	if (!atomic_inc_not_zero(&d->ref))
>> +	if (!d || !atomic_inc_not_zero(&d->ref))
> 
> This makes more sense, no?
> +	if (d && !atomic_inc_not_zero(&d->ref))
> 
> Benny
> 
>>  		d = NULL;

Sure, since then d is already set to NULL, I guess

>>  	rcu_read_unlock();
>>  	return d;
> 

Boaz
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Benny Halevy May 24, 2011, 5:02 p.m. UTC | #3
On 2011-05-24 20:00, Boaz Harrosh wrote:
> On 05/24/2011 07:52 PM, Benny Halevy wrote:
>> On 2011-05-24 18:04, Boaz Harrosh wrote:
>>> NULL deref on first ever call. (When device is not found)
>>>
>>> Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
>>> ---
>>>  fs/nfs/pnfs_dev.c |    2 +-
>>>  1 files changed, 1 insertions(+), 1 deletions(-)
>>>
>>> diff --git a/fs/nfs/pnfs_dev.c b/fs/nfs/pnfs_dev.c
>>> index 7997899..7e5542c 100644
>>> --- a/fs/nfs/pnfs_dev.c
>>> +++ b/fs/nfs/pnfs_dev.c
>>> @@ -100,7 +100,7 @@ _find_get_deviceid(const struct pnfs_layoutdriver_type *ld,
>>>  
>>>  	rcu_read_lock();
>>>  	d = _lookup_deviceid(ld, clp, id, hash);
>>> -	if (!atomic_inc_not_zero(&d->ref))
>>> +	if (!d || !atomic_inc_not_zero(&d->ref))
>>
>> This makes more sense, no?
>> +	if (d && !atomic_inc_not_zero(&d->ref))
>>
>> Benny
>>
>>>  		d = NULL;
> 
> Sure, since then d is already set to NULL, I guess
> 

Right.

>>>  	rcu_read_unlock();
>>>  	return d;
>>
> 
> Boaz

--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/fs/nfs/pnfs_dev.c b/fs/nfs/pnfs_dev.c
index 7997899..7e5542c 100644
--- a/fs/nfs/pnfs_dev.c
+++ b/fs/nfs/pnfs_dev.c
@@ -100,7 +100,7 @@  _find_get_deviceid(const struct pnfs_layoutdriver_type *ld,
 
 	rcu_read_lock();
 	d = _lookup_deviceid(ld, clp, id, hash);
-	if (!atomic_inc_not_zero(&d->ref))
+	if (!d || !atomic_inc_not_zero(&d->ref))
 		d = NULL;
 	rcu_read_unlock();
 	return d;