All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] staging: vme: fix issues in vme_register_bridge
@ 2011-02-23 13:25 Manohar Vanga
  2011-02-23 13:25 ` [PATCH 1/2] staging: vme: remove unreachable code Manohar Vanga
  2011-02-23 13:25 ` [PATCH 2/2] staging: vme: fix loop condition Manohar Vanga
  0 siblings, 2 replies; 12+ messages in thread
From: Manohar Vanga @ 2011-02-23 13:25 UTC (permalink / raw)
  To: martyn.welch; +Cc: gregkh, wfp5p, cota, devel, linux-kernel, Manohar Vanga

This patchset fixes two issues I found in vme_register_bridge. 
The first gets rid of some unreachable code and the second one fixes 
a bug that could potentially lead to an infinite loop in the event
that device_register fails.

Please skip the previous patchset I sent and reacknowledge these.
Apologies for the noise pollution.

Thanks,
Manohar Vanga

Manohar Vanga (2):
  staging: vme: remove unreachable code
  staging: vme: fix loop condition

 drivers/staging/vme/vme.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 1/2] staging: vme: remove unreachable code
  2011-02-23 13:25 [PATCH 0/2] staging: vme: fix issues in vme_register_bridge Manohar Vanga
@ 2011-02-23 13:25 ` Manohar Vanga
  2011-02-23 13:56   ` Dan Carpenter
  2011-02-23 17:00   ` Martyn Welch
  2011-02-23 13:25 ` [PATCH 2/2] staging: vme: fix loop condition Manohar Vanga
  1 sibling, 2 replies; 12+ messages in thread
From: Manohar Vanga @ 2011-02-23 13:25 UTC (permalink / raw)
  To: martyn.welch; +Cc: gregkh, wfp5p, cota, devel, linux-kernel, Manohar Vanga

Removed some unreachable code from vme_register_bridge

Signed-off-by: Manohar Vanga <manohar.vanga@cern.ch>
---
 drivers/staging/vme/vme.c |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/vme/vme.c b/drivers/staging/vme/vme.c
index d9fc864..88bf455 100644
--- a/drivers/staging/vme/vme.c
+++ b/drivers/staging/vme/vme.c
@@ -1363,7 +1363,6 @@ int vme_register_bridge(struct vme_bridge *bridge)
 
 	return retval;
 
-	i = VME_SLOTS_MAX;
 err_reg:
 	while (i > -1) {
 		dev = &bridge->dev[i];
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 2/2] staging: vme: fix loop condition
  2011-02-23 13:25 [PATCH 0/2] staging: vme: fix issues in vme_register_bridge Manohar Vanga
  2011-02-23 13:25 ` [PATCH 1/2] staging: vme: remove unreachable code Manohar Vanga
@ 2011-02-23 13:25 ` Manohar Vanga
  2011-02-23 13:57   ` Dan Carpenter
  2011-02-23 17:01   ` Martyn Welch
  1 sibling, 2 replies; 12+ messages in thread
From: Manohar Vanga @ 2011-02-23 13:25 UTC (permalink / raw)
  To: martyn.welch; +Cc: gregkh, wfp5p, cota, devel, linux-kernel, Manohar Vanga

Fix loop condition in vme_register_bridge that results in an infinite
loop in the event that device_register fails.

Signed-off-by: Manohar Vanga <manohar.vanga@cern.ch>
---
 drivers/staging/vme/vme.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/vme/vme.c b/drivers/staging/vme/vme.c
index 88bf455..c1ec230 100644
--- a/drivers/staging/vme/vme.c
+++ b/drivers/staging/vme/vme.c
@@ -1364,7 +1364,7 @@ int vme_register_bridge(struct vme_bridge *bridge)
 	return retval;
 
 err_reg:
-	while (i > -1) {
+	while (--i >= 0) {
 		dev = &bridge->dev[i];
 		device_unregister(dev);
 	}
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH 1/2] staging: vme: remove unreachable code
  2011-02-23 13:25 ` [PATCH 1/2] staging: vme: remove unreachable code Manohar Vanga
@ 2011-02-23 13:56   ` Dan Carpenter
  2011-02-23 17:00   ` Martyn Welch
  1 sibling, 0 replies; 12+ messages in thread
From: Dan Carpenter @ 2011-02-23 13:56 UTC (permalink / raw)
  To: Manohar Vanga; +Cc: martyn.welch, devel, gregkh, cota, linux-kernel

On Wed, Feb 23, 2011 at 02:25:27PM +0100, Manohar Vanga wrote:
> Removed some unreachable code from vme_register_bridge
> 
> Signed-off-by: Manohar Vanga <manohar.vanga@cern.ch>

Acked-by: Dan Carpenter <error27@gmail.com>



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 2/2] staging: vme: fix loop condition
  2011-02-23 13:25 ` [PATCH 2/2] staging: vme: fix loop condition Manohar Vanga
@ 2011-02-23 13:57   ` Dan Carpenter
  2011-02-23 17:01   ` Martyn Welch
  1 sibling, 0 replies; 12+ messages in thread
From: Dan Carpenter @ 2011-02-23 13:57 UTC (permalink / raw)
  To: Manohar Vanga; +Cc: martyn.welch, devel, gregkh, cota, linux-kernel

On Wed, Feb 23, 2011 at 02:25:28PM +0100, Manohar Vanga wrote:
> Fix loop condition in vme_register_bridge that results in an infinite
> loop in the event that device_register fails.
> 

Acked-by: Dan Carpenter <error27@gmail.com>


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 1/2] staging: vme: remove unreachable code
  2011-02-23 13:25 ` [PATCH 1/2] staging: vme: remove unreachable code Manohar Vanga
  2011-02-23 13:56   ` Dan Carpenter
@ 2011-02-23 17:00   ` Martyn Welch
  1 sibling, 0 replies; 12+ messages in thread
From: Martyn Welch @ 2011-02-23 17:00 UTC (permalink / raw)
  To: Manohar Vanga; +Cc: gregkh, wfp5p, cota, devel, linux-kernel

On 23/02/11 13:25, Manohar Vanga wrote:
> Removed some unreachable code from vme_register_bridge
> 
> Signed-off-by: Manohar Vanga <manohar.vanga@cern.ch>

Acked-by: Martyn Welch <martyn.welch@ge.com>

> ---
>  drivers/staging/vme/vme.c |    1 -
>  1 files changed, 0 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/staging/vme/vme.c b/drivers/staging/vme/vme.c
> index d9fc864..88bf455 100644
> --- a/drivers/staging/vme/vme.c
> +++ b/drivers/staging/vme/vme.c
> @@ -1363,7 +1363,6 @@ int vme_register_bridge(struct vme_bridge *bridge)
>  
>  	return retval;
>  
> -	i = VME_SLOTS_MAX;
>  err_reg:
>  	while (i > -1) {
>  		dev = &bridge->dev[i];


-- 
Martyn Welch (Principal Software Engineer) | Registered in England and
GE Intelligent Platforms                   | Wales (3828642) at 100
T +44(0)127322748                          | Barbirolli Square, Manchester,
E martyn.welch@ge.com                      | M2 3AB  VAT:GB 927559189

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 2/2] staging: vme: fix loop condition
  2011-02-23 13:25 ` [PATCH 2/2] staging: vme: fix loop condition Manohar Vanga
  2011-02-23 13:57   ` Dan Carpenter
@ 2011-02-23 17:01   ` Martyn Welch
  1 sibling, 0 replies; 12+ messages in thread
From: Martyn Welch @ 2011-02-23 17:01 UTC (permalink / raw)
  To: Manohar Vanga; +Cc: gregkh, wfp5p, cota, devel, linux-kernel

On 23/02/11 13:25, Manohar Vanga wrote:
> Fix loop condition in vme_register_bridge that results in an infinite
> loop in the event that device_register fails.
> 
> Signed-off-by: Manohar Vanga <manohar.vanga@cern.ch>

Acked-by: Martyn Welch <martyn.welch@ge.com>

> ---
>  drivers/staging/vme/vme.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/staging/vme/vme.c b/drivers/staging/vme/vme.c
> index 88bf455..c1ec230 100644
> --- a/drivers/staging/vme/vme.c
> +++ b/drivers/staging/vme/vme.c
> @@ -1364,7 +1364,7 @@ int vme_register_bridge(struct vme_bridge *bridge)
>  	return retval;
>  
>  err_reg:
> -	while (i > -1) {
> +	while (--i >= 0) {
>  		dev = &bridge->dev[i];
>  		device_unregister(dev);
>  	}


-- 
Martyn Welch (Principal Software Engineer) | Registered in England and
GE Intelligent Platforms                   | Wales (3828642) at 100
T +44(0)127322748                          | Barbirolli Square, Manchester,
E martyn.welch@ge.com                      | M2 3AB  VAT:GB 927559189

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 1/2] Staging: vme: remove unreachable code
  2011-02-23 15:16         ` Manohar Vanga
@ 2011-02-23 15:19           ` Martyn Welch
  0 siblings, 0 replies; 12+ messages in thread
From: Martyn Welch @ 2011-02-23 15:19 UTC (permalink / raw)
  To: Manohar Vanga; +Cc: Dan Carpenter, devel, cota, linux-kernel

On 23/02/11 15:16, Manohar Vanga wrote:
>>> There are two problems with this loop.  1) It unregisters the device
>>> which failed to register.  2) It is a forever loop.
>>>
>>
>> Even if "i" is a signed int?
> 
> The infinite loop is because "i" is not decremented anywhere in the loop. Not
> because of signedness.
> 

Ah, yeah, that would help.

Martyn

> Thanks,
> Manohar Vanga


-- 
Martyn Welch (Principal Software Engineer) | Registered in England and
GE Intelligent Platforms                   | Wales (3828642) at 100
T +44(0)127322748                          | Barbirolli Square, Manchester,
E martyn.welch@ge.com                      | M2 3AB  VAT:GB 927559189

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 1/2] Staging: vme: remove unreachable code
  2011-02-23 15:09       ` Martyn Welch
@ 2011-02-23 15:16         ` Manohar Vanga
  2011-02-23 15:19           ` Martyn Welch
  0 siblings, 1 reply; 12+ messages in thread
From: Manohar Vanga @ 2011-02-23 15:16 UTC (permalink / raw)
  To: Martyn Welch; +Cc: Dan Carpenter, devel, cota, linux-kernel

> > There are two problems with this loop.  1) It unregisters the device
> > which failed to register.  2) It is a forever loop.
> > 
> 
> Even if "i" is a signed int?

The infinite loop is because "i" is not decremented anywhere in the loop. Not
because of signedness.

Thanks,
Manohar Vanga

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 1/2] Staging: vme: remove unreachable code
  2011-02-23 12:17     ` Dan Carpenter
@ 2011-02-23 15:09       ` Martyn Welch
  2011-02-23 15:16         ` Manohar Vanga
  0 siblings, 1 reply; 12+ messages in thread
From: Martyn Welch @ 2011-02-23 15:09 UTC (permalink / raw)
  To: Dan Carpenter, Manohar Vanga, devel, cota, linux-kernel

On 23/02/11 12:17, Dan Carpenter wrote:
> On Wed, Feb 23, 2011 at 09:19:06AM +0000, Martyn Welch wrote:
>> On 22/02/11 19:36, Manohar Vanga wrote:
>>> Remove unreachable code from vme_register_bridge
>>>
>>> Signed-off-by: Manohar Vanga <manohar.vanga@cern.ch>
> 
> Please always CC the list.  It's going to be Greg to commit this
> code so CC Greg as well.
> 
> ./scripts/get_maintainer.pl patch.diff
> 
> (Although you should generally remove Tejun from the CC list.)
> 
>>
>> Yeah - that's there from development. If the function needed to be extended,
>> that's the next part of the error path.
> 
> Don't do that.  Kernel style is austere.  Anything that isn't needed
> here and now should be removed.
> 
>>> --- a/drivers/staging/vme/vme.c
>>> +++ b/drivers/staging/vme/vme.c
>>> @@ -1363,7 +1363,6 @@ int vme_register_bridge(struct vme_bridge *bridge)
>>>  
>>>  	return retval;
>>>  
>>> -	i = VME_SLOTS_MAX;
>>>  err_reg:
>>>  	while (i > -1) {
>>>  		dev = &bridge->dev[i];
> 
> There are two problems with this loop.  1) It unregisters the device
> which failed to register.  2) It is a forever loop.
> 

Even if "i" is a signed int?

> It should be:
> 	while (--i >= 0) {
> 		dev = &bridge->dev[i];
> 
> Can you fix that up as well and resend.
> 
> regards,
> dan carpenter


-- 
Martyn Welch (Principal Software Engineer) | Registered in England and
GE Intelligent Platforms                   | Wales (3828642) at 100
T +44(0)127322748                          | Barbirolli Square, Manchester,
E martyn.welch@ge.com                      | M2 3AB  VAT:GB 927559189

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 1/2] Staging: vme: remove unreachable code
  2011-02-23  9:19   ` [PATCH 1/2] Staging: vme: remove unreachable code Martyn Welch
@ 2011-02-23 12:17     ` Dan Carpenter
  2011-02-23 15:09       ` Martyn Welch
  0 siblings, 1 reply; 12+ messages in thread
From: Dan Carpenter @ 2011-02-23 12:17 UTC (permalink / raw)
  To: Martyn Welch; +Cc: Manohar Vanga, devel, cota, linux-kernel

On Wed, Feb 23, 2011 at 09:19:06AM +0000, Martyn Welch wrote:
> On 22/02/11 19:36, Manohar Vanga wrote:
> > Remove unreachable code from vme_register_bridge
> > 
> > Signed-off-by: Manohar Vanga <manohar.vanga@cern.ch>

Please always CC the list.  It's going to be Greg to commit this
code so CC Greg as well.

./scripts/get_maintainer.pl patch.diff

(Although you should generally remove Tejun from the CC list.)

> 
> Yeah - that's there from development. If the function needed to be extended,
> that's the next part of the error path.

Don't do that.  Kernel style is austere.  Anything that isn't needed
here and now should be removed.

> > --- a/drivers/staging/vme/vme.c
> > +++ b/drivers/staging/vme/vme.c
> > @@ -1363,7 +1363,6 @@ int vme_register_bridge(struct vme_bridge *bridge)
> >  
> >  	return retval;
> >  
> > -	i = VME_SLOTS_MAX;
> >  err_reg:
> >  	while (i > -1) {
> >  		dev = &bridge->dev[i];

There are two problems with this loop.  1) It unregisters the device
which failed to register.  2) It is a forever loop.

It should be:
	while (--i >= 0) {
		dev = &bridge->dev[i];

Can you fix that up as well and resend.

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 1/2] Staging: vme: remove unreachable code
       [not found] ` <1298403376-28352-2-git-send-email-manohar.vanga@cern.ch>
@ 2011-02-23  9:19   ` Martyn Welch
  2011-02-23 12:17     ` Dan Carpenter
  0 siblings, 1 reply; 12+ messages in thread
From: Martyn Welch @ 2011-02-23  9:19 UTC (permalink / raw)
  To: Manohar Vanga; +Cc: cota, devel, linux-kernel, Greg KH

On 22/02/11 19:36, Manohar Vanga wrote:
> Remove unreachable code from vme_register_bridge
> 
> Signed-off-by: Manohar Vanga <manohar.vanga@cern.ch>

Yeah - that's there from development. If the function needed to be extended,
that's the next part of the error path.

Not sure how leaving lines like this are viewed in the kernel code, I'm happy
for this to be removed if it's not considered good practice. In that case:

Acked-by: Martyn Welch <martyn.welch@ge.com>

Martyn

> ---
>  drivers/staging/vme/vme.c |    1 -
>  1 files changed, 0 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/staging/vme/vme.c b/drivers/staging/vme/vme.c
> index d9fc864..88bf455 100644
> --- a/drivers/staging/vme/vme.c
> +++ b/drivers/staging/vme/vme.c
> @@ -1363,7 +1363,6 @@ int vme_register_bridge(struct vme_bridge *bridge)
>  
>  	return retval;
>  
> -	i = VME_SLOTS_MAX;
>  err_reg:
>  	while (i > -1) {
>  		dev = &bridge->dev[i];


-- 
Martyn Welch (Principal Software Engineer) | Registered in England and
GE Intelligent Platforms                   | Wales (3828642) at 100
T +44(0)127322748                          | Barbirolli Square, Manchester,
E martyn.welch@ge.com                      | M2 3AB  VAT:GB 927559189

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2011-02-23 17:01 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-23 13:25 [PATCH 0/2] staging: vme: fix issues in vme_register_bridge Manohar Vanga
2011-02-23 13:25 ` [PATCH 1/2] staging: vme: remove unreachable code Manohar Vanga
2011-02-23 13:56   ` Dan Carpenter
2011-02-23 17:00   ` Martyn Welch
2011-02-23 13:25 ` [PATCH 2/2] staging: vme: fix loop condition Manohar Vanga
2011-02-23 13:57   ` Dan Carpenter
2011-02-23 17:01   ` Martyn Welch
     [not found] <1298403376-28352-1-git-send-email-manohar.vanga@cern.ch>
     [not found] ` <1298403376-28352-2-git-send-email-manohar.vanga@cern.ch>
2011-02-23  9:19   ` [PATCH 1/2] Staging: vme: remove unreachable code Martyn Welch
2011-02-23 12:17     ` Dan Carpenter
2011-02-23 15:09       ` Martyn Welch
2011-02-23 15:16         ` Manohar Vanga
2011-02-23 15:19           ` Martyn Welch

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.