* [PATCH] pcnet: fix sparse triviality
@ 2007-10-26 22:11 Auke Kok
2007-10-29 10:04 ` Jeff Garzik
0 siblings, 1 reply; 3+ messages in thread
From: Auke Kok @ 2007-10-26 22:11 UTC (permalink / raw)
To: pcnet32; +Cc: netdev
Since data can never exceed u32, it can't even be larger than LONG_MAX/HZ.
Signed-off-by: Auke Kok <auke-jan.h.kok@intel.com>
Cc: pcnet32@verizon.net
---
drivers/net/pcnet32.c | 5 ++---
1 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/net/pcnet32.c b/drivers/net/pcnet32.c
index ff92aca..3573e77 100644
--- a/drivers/net/pcnet32.c
+++ b/drivers/net/pcnet32.c
@@ -1101,9 +1101,8 @@ static int pcnet32_phys_id(struct net_device *dev, u32 data)
mod_timer(&lp->blink_timer, jiffies);
set_current_state(TASK_INTERRUPTIBLE);
- /* AV: the limit here makes no sense whatsoever */
- if ((!data) || (data > (u32) (MAX_SCHEDULE_TIMEOUT / HZ)))
- data = (u32) (MAX_SCHEDULE_TIMEOUT / HZ);
+ if (!data)
+ data = INT_MAX;
msleep_interruptible(data * 1000);
del_timer_sync(&lp->blink_timer);
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] pcnet: fix sparse triviality
2007-10-26 22:11 [PATCH] pcnet: fix sparse triviality Auke Kok
@ 2007-10-29 10:04 ` Jeff Garzik
2007-10-29 17:54 ` Kok, Auke
0 siblings, 1 reply; 3+ messages in thread
From: Jeff Garzik @ 2007-10-29 10:04 UTC (permalink / raw)
To: Auke Kok; +Cc: pcnet32, netdev
Auke Kok wrote:
> Since data can never exceed u32, it can't even be larger than LONG_MAX/HZ.
>
> Signed-off-by: Auke Kok <auke-jan.h.kok@intel.com>
> Cc: pcnet32@verizon.net
> ---
>
> drivers/net/pcnet32.c | 5 ++---
> 1 files changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/net/pcnet32.c b/drivers/net/pcnet32.c
> index ff92aca..3573e77 100644
> --- a/drivers/net/pcnet32.c
> +++ b/drivers/net/pcnet32.c
> @@ -1101,9 +1101,8 @@ static int pcnet32_phys_id(struct net_device *dev, u32 data)
> mod_timer(&lp->blink_timer, jiffies);
> set_current_state(TASK_INTERRUPTIBLE);
>
> - /* AV: the limit here makes no sense whatsoever */
> - if ((!data) || (data > (u32) (MAX_SCHEDULE_TIMEOUT / HZ)))
> - data = (u32) (MAX_SCHEDULE_TIMEOUT / HZ);
> + if (!data)
> + data = INT_MAX;
>
> msleep_interruptible(data * 1000);
> del_timer_sync(&lp->blink_timer);
Two comments:
1) I would prefer to pick a sane limit, like "1 day". The unit of
'data' is seconds, so IMO we should not allow stupid timeouts, much less
INT_MAX ones :) But hey, then again, maybe we should permit root to
hang themselves with own rope...
2) [tangent] someone really should add the obvious ssleep_interruptible()
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] pcnet: fix sparse triviality
2007-10-29 10:04 ` Jeff Garzik
@ 2007-10-29 17:54 ` Kok, Auke
0 siblings, 0 replies; 3+ messages in thread
From: Kok, Auke @ 2007-10-29 17:54 UTC (permalink / raw)
To: Jeff Garzik; +Cc: pcnet32, netdev
Jeff Garzik wrote:
> Auke Kok wrote:
>> Since data can never exceed u32, it can't even be larger than
>> LONG_MAX/HZ.
>>
>> Signed-off-by: Auke Kok <auke-jan.h.kok@intel.com>
>> Cc: pcnet32@verizon.net
>> ---
>>
> Two comments:
>
> 1) I would prefer to pick a sane limit, like "1 day". The unit of
> 'data' is seconds, so IMO we should not allow stupid timeouts, much less
> INT_MAX ones :) But hey, then again, maybe we should permit root to
> hang themselves with own rope...
well, in this case it's only used for the blink interval for the LED on the back
of the adapter. This is completely interruptable by the user with ^C when running
ethtool, so it's not going to hang anything (traffic should continue nicely).
yes INT_MAX is insanely long. moving all of this checking to the ethtool generic
code makes much more sense indeed.
> 2) [tangent] someone really should add the obvious ssleep_interruptible()
*pass* :)
Auke
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-10-29 18:03 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-10-26 22:11 [PATCH] pcnet: fix sparse triviality Auke Kok
2007-10-29 10:04 ` Jeff Garzik
2007-10-29 17:54 ` Kok, Auke
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).