public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/6] MIPS: irixelf: fix test unsigned var < 0
@ 2008-04-16  1:39 Roel Kluin
  2008-04-16 15:27 ` Roel Kluin
                   ` (4 more replies)
  0 siblings, 5 replies; 10+ messages in thread
From: Roel Kluin @ 2008-04-16  1:39 UTC (permalink / raw)
  To: ralf; +Cc: linux-mips, lkml

v is unsigned, cast to signed to evaluate the do_brk() return value,
    
Signed-off-by: Roel Kluin <12o3l@tiscali.nl>
---
diff --git a/arch/mips/kernel/irixelf.c b/arch/mips/kernel/irixelf.c
index 290d8e3..fad2a2a 100644
--- a/arch/mips/kernel/irixelf.c
+++ b/arch/mips/kernel/irixelf.c
@@ -583,15 +583,15 @@ static void irix_map_prda_page(void)
 	unsigned long v;
 	struct prda *pp;
 
 	down_write(&current->mm->mmap_sem);
 	v =  do_brk(PRDA_ADDRESS, PAGE_SIZE);
 	up_write(&current->mm->mmap_sem);
 
-	if (v < 0)
+	if ((long) v < 0)
 		return;
 
 	pp = (struct prda *) v;
 	pp->prda_sys.t_pid  = task_pid_vnr(current);
 	pp->prda_sys.t_prid = read_c0_prid();
 	pp->prda_sys.t_rpid = task_pid_vnr(current);
 


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

* Re: [PATCH 1/6] MIPS: irixelf: fix test unsigned var < 0
  2008-04-16  1:39 [PATCH 1/6] MIPS: irixelf: fix test unsigned var < 0 Roel Kluin
@ 2008-04-16 15:27 ` Roel Kluin
  2008-04-16 15:32   ` [PATCH 4/6] RTC: rtc-ds1374: fix unsigned new_alarm test Roel Kluin
  2008-04-16 16:00 ` [PATCH 5/6] NETFILTER: signed tcphoff for ipv6_skip_exthdr() retval Roel Kluin
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 10+ messages in thread
From: Roel Kluin @ 2008-04-16 15:27 UTC (permalink / raw)
  To: a.zummo; +Cc: rtc-linux, lkml

New_alarm is unsigned so the test didn't work.
    
Signed-off-by: Roel Kluin <12o3l@tiscali.nl>
---
diff --git a/drivers/rtc/rtc-ds1374.c b/drivers/rtc/rtc-ds1374.c
index 45bda18..119bdc9 100644
--- a/drivers/rtc/rtc-ds1374.c
+++ b/drivers/rtc/rtc-ds1374.c
@@ -216,16 +216,16 @@ static int ds1374_set_alarm(struct device *dev, struct rtc_wkalrm *alarm)
 	rtc_tm_to_time(&alarm->time, &new_alarm);
 	rtc_tm_to_time(&now, &itime);
 
-	new_alarm -= itime;
-
 	/* This can happen due to races, in addition to dates that are
 	 * truly in the past.  To avoid requiring the caller to check for
 	 * races, dates in the past are assumed to be in the recent past
 	 * (i.e. not something that we'd rather the caller know about via
 	 * an error), and the alarm is set to go off as soon as possible.
 	 */
-	if (new_alarm <= 0)
+	if (new_alarm <= itime)
 		new_alarm = 1;
+	else
+		new_alarm -= itime;
 
 	mutex_lock(&ds1374->mutex);
 


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

* [PATCH 4/6] RTC: rtc-ds1374: fix unsigned new_alarm test
  2008-04-16 15:27 ` Roel Kluin
@ 2008-04-16 15:32   ` Roel Kluin
  2008-04-18 21:58     ` Alessandro Zummo
  0 siblings, 1 reply; 10+ messages in thread
From: Roel Kluin @ 2008-04-16 15:32 UTC (permalink / raw)
  To: a.zummo; +Cc: rtc-linux, lkml

Sorry for the duplicate, I forgot to fix the email header
---
New_alarm is unsigned so the test didn't work.
    
Signed-off-by: Roel Kluin <12o3l@tiscali.nl>
---
diff --git a/drivers/rtc/rtc-ds1374.c b/drivers/rtc/rtc-ds1374.c
index 45bda18..119bdc9 100644
--- a/drivers/rtc/rtc-ds1374.c
+++ b/drivers/rtc/rtc-ds1374.c
@@ -216,16 +216,16 @@ static int ds1374_set_alarm(struct device *dev, struct rtc_wkalrm *alarm)
 	rtc_tm_to_time(&alarm->time, &new_alarm);
 	rtc_tm_to_time(&now, &itime);
 
-	new_alarm -= itime;
-
 	/* This can happen due to races, in addition to dates that are
 	 * truly in the past.  To avoid requiring the caller to check for
 	 * races, dates in the past are assumed to be in the recent past
 	 * (i.e. not something that we'd rather the caller know about via
 	 * an error), and the alarm is set to go off as soon as possible.
 	 */
-	if (new_alarm <= 0)
+	if (new_alarm <= itime)
 		new_alarm = 1;
+	else
+		new_alarm -= itime;
 
 	mutex_lock(&ds1374->mutex);
 


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

* [PATCH 5/6] NETFILTER: signed tcphoff for ipv6_skip_exthdr() retval
  2008-04-16  1:39 [PATCH 1/6] MIPS: irixelf: fix test unsigned var < 0 Roel Kluin
  2008-04-16 15:27 ` Roel Kluin
@ 2008-04-16 16:00 ` Roel Kluin
  2008-04-21 12:24   ` [netfilter-core] " Patrick McHardy
  2008-04-16 16:20 ` [PATCH 6/6] sound/drivers/dummy.c: fix negative snd_pcm_format_width() check Roel Kluin
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 10+ messages in thread
From: Roel Kluin @ 2008-04-16 16:00 UTC (permalink / raw)
  To: Jan Engelhardt; +Cc: kaber, netfilter-devel, netfilter, coreteam, lkml

if tcphoff remains unsigned, a negative ipv6_skip_exthdr() return value will
go unnoticed,
    
Signed-off-by: Roel Kluin <12o3l@tiscali.nl>
---
diff --git a/net/netfilter/xt_TCPOPTSTRIP.c b/net/netfilter/xt_TCPOPTSTRIP.c
index 3b2aa56..9685b6f 100644
--- a/net/netfilter/xt_TCPOPTSTRIP.c
+++ b/net/netfilter/xt_TCPOPTSTRIP.c
@@ -90,7 +90,7 @@ tcpoptstrip_tg6(struct sk_buff *skb, const struct net_device *in,
 		const struct xt_target *target, const void *targinfo)
 {
 	struct ipv6hdr *ipv6h = ipv6_hdr(skb);
-	unsigned int tcphoff;
+	int tcphoff;
 	u_int8_t nexthdr;
 
 	nexthdr = ipv6h->nexthdr;


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

* [PATCH 6/6] sound/drivers/dummy.c: fix negative snd_pcm_format_width() check
  2008-04-16  1:39 [PATCH 1/6] MIPS: irixelf: fix test unsigned var < 0 Roel Kluin
  2008-04-16 15:27 ` Roel Kluin
  2008-04-16 16:00 ` [PATCH 5/6] NETFILTER: signed tcphoff for ipv6_skip_exthdr() retval Roel Kluin
@ 2008-04-16 16:20 ` Roel Kluin
  2008-04-16 16:31   ` [alsa-devel] " Takashi Iwai
  2008-04-16 18:00 ` [PATCH 1/6] MIPS: irixelf: fix test unsigned var < 0 Ralf Baechle
  2008-04-16 19:39 ` Marcin Slusarz
  4 siblings, 1 reply; 10+ messages in thread
From: Roel Kluin @ 2008-04-16 16:20 UTC (permalink / raw)
  To: perex; +Cc: alsa-devel, lkml

bps is unsigned, a negative snd_pcm_format_width() return value is not noticed
    
Signed-off-by: Roel Kluin <12o3l@tiscali.nl>
---
diff --git a/sound/drivers/dummy.c b/sound/drivers/dummy.c
index a240eae..1c88977 100644
--- a/sound/drivers/dummy.c
+++ b/sound/drivers/dummy.c
@@ -230,13 +230,14 @@ static int snd_card_dummy_pcm_prepare(struct snd_pcm_substream *substream)
 {
 	struct snd_pcm_runtime *runtime = substream->runtime;
 	struct snd_dummy_pcm *dpcm = runtime->private_data;
-	unsigned int bps;
+	int bps;
+
+	bps = snd_pcm_format_width(runtime->format) * runtime->rate *
+		runtime->channels / 8;
 
-	bps = runtime->rate * runtime->channels;
-	bps *= snd_pcm_format_width(runtime->format);
-	bps /= 8;
 	if (bps <= 0)
 		return -EINVAL;
+
 	dpcm->pcm_bps = bps;
 	dpcm->pcm_jiffie = bps / HZ;
 	dpcm->pcm_size = snd_pcm_lib_buffer_bytes(substream);

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

* Re: [alsa-devel] [PATCH 6/6] sound/drivers/dummy.c: fix negative snd_pcm_format_width() check
  2008-04-16 16:20 ` [PATCH 6/6] sound/drivers/dummy.c: fix negative snd_pcm_format_width() check Roel Kluin
@ 2008-04-16 16:31   ` Takashi Iwai
  0 siblings, 0 replies; 10+ messages in thread
From: Takashi Iwai @ 2008-04-16 16:31 UTC (permalink / raw)
  To: Roel Kluin; +Cc: perex, alsa-devel, lkml

At Wed, 16 Apr 2008 18:20:33 +0200,
Roel Kluin wrote:
> 
> bps is unsigned, a negative snd_pcm_format_width() return value is not noticed
>     
> Signed-off-by: Roel Kluin <12o3l@tiscali.nl>

Applied to ALSA tree.  Thanks.


Takashi

> ---
> diff --git a/sound/drivers/dummy.c b/sound/drivers/dummy.c
> index a240eae..1c88977 100644
> --- a/sound/drivers/dummy.c
> +++ b/sound/drivers/dummy.c
> @@ -230,13 +230,14 @@ static int snd_card_dummy_pcm_prepare(struct snd_pcm_substream *substream)
>  {
>  	struct snd_pcm_runtime *runtime = substream->runtime;
>  	struct snd_dummy_pcm *dpcm = runtime->private_data;
> -	unsigned int bps;
> +	int bps;
> +
> +	bps = snd_pcm_format_width(runtime->format) * runtime->rate *
> +		runtime->channels / 8;
>  
> -	bps = runtime->rate * runtime->channels;
> -	bps *= snd_pcm_format_width(runtime->format);
> -	bps /= 8;
>  	if (bps <= 0)
>  		return -EINVAL;
> +
>  	dpcm->pcm_bps = bps;
>  	dpcm->pcm_jiffie = bps / HZ;
>  	dpcm->pcm_size = snd_pcm_lib_buffer_bytes(substream);
> _______________________________________________
> Alsa-devel mailing list
> Alsa-devel@alsa-project.org
> http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
> 

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

* Re: [PATCH 1/6] MIPS: irixelf: fix test unsigned var < 0
  2008-04-16  1:39 [PATCH 1/6] MIPS: irixelf: fix test unsigned var < 0 Roel Kluin
                   ` (2 preceding siblings ...)
  2008-04-16 16:20 ` [PATCH 6/6] sound/drivers/dummy.c: fix negative snd_pcm_format_width() check Roel Kluin
@ 2008-04-16 18:00 ` Ralf Baechle
  2008-04-16 19:39 ` Marcin Slusarz
  4 siblings, 0 replies; 10+ messages in thread
From: Ralf Baechle @ 2008-04-16 18:00 UTC (permalink / raw)
  To: Roel Kluin; +Cc: linux-mips, lkml

On Wed, Apr 16, 2008 at 03:39:22AM +0200, Roel Kluin wrote:

> v is unsigned, cast to signed to evaluate the do_brk() return value,

do_brk() is expected to return its first argument as the result in case
of success.  An error also wasn't getting propagated so some further
fixes were needed for irix_map_prda_page and its caller.  So I'll apply
a different fix.

Thanks!

  Ralf

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

* Re: [PATCH 1/6] MIPS: irixelf: fix test unsigned var < 0
  2008-04-16  1:39 [PATCH 1/6] MIPS: irixelf: fix test unsigned var < 0 Roel Kluin
                   ` (3 preceding siblings ...)
  2008-04-16 18:00 ` [PATCH 1/6] MIPS: irixelf: fix test unsigned var < 0 Ralf Baechle
@ 2008-04-16 19:39 ` Marcin Slusarz
  4 siblings, 0 replies; 10+ messages in thread
From: Marcin Slusarz @ 2008-04-16 19:39 UTC (permalink / raw)
  To: Roel Kluin; +Cc: ralf, linux-mips, lkml

On Wed, Apr 16, 2008 at 03:39:22AM +0200, Roel Kluin wrote:
> v is unsigned, cast to signed to evaluate the do_brk() return value,
>     
> Signed-off-by: Roel Kluin <12o3l@tiscali.nl>
> ---
> diff --git a/arch/mips/kernel/irixelf.c b/arch/mips/kernel/irixelf.c
> index 290d8e3..fad2a2a 100644
> --- a/arch/mips/kernel/irixelf.c
> +++ b/arch/mips/kernel/irixelf.c
> @@ -583,15 +583,15 @@ static void irix_map_prda_page(void)
>  	unsigned long v;
>  	struct prda *pp;
>  
>  	down_write(&current->mm->mmap_sem);
>  	v =  do_brk(PRDA_ADDRESS, PAGE_SIZE);
>  	up_write(&current->mm->mmap_sem);
>  
> -	if (v < 0)
> +	if ((long) v < 0)
maybe cast it earlier (to struct prda *) and check error with IS_ERR?

>  		return;
>  
>  	pp = (struct prda *) v;
>  	pp->prda_sys.t_pid  = task_pid_vnr(current);
>  	pp->prda_sys.t_prid = read_c0_prid();
>  	pp->prda_sys.t_rpid = task_pid_vnr(current);
>  
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

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

* Re: [PATCH 4/6] RTC: rtc-ds1374: fix unsigned new_alarm test
  2008-04-16 15:32   ` [PATCH 4/6] RTC: rtc-ds1374: fix unsigned new_alarm test Roel Kluin
@ 2008-04-18 21:58     ` Alessandro Zummo
  0 siblings, 0 replies; 10+ messages in thread
From: Alessandro Zummo @ 2008-04-18 21:58 UTC (permalink / raw)
  To: Roel Kluin; +Cc: rtc-linux, lkml, akpm

On Wed, 16 Apr 2008 17:32:28 +0200
Roel Kluin <12o3l@tiscali.nl> wrote:

> New_alarm is unsigned so the test didn't work.
>     
> Signed-off-by: Roel Kluin <12o3l@tiscali.nl>

 Acked-by: Alessandro Zummo <a.zummo@towertech.it>

-- 

 Best regards,

 Alessandro Zummo,
  Tower Technologies - Torino, Italy

  http://www.towertech.it


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

* Re: [netfilter-core] [PATCH 5/6] NETFILTER: signed tcphoff for ipv6_skip_exthdr() retval
  2008-04-16 16:00 ` [PATCH 5/6] NETFILTER: signed tcphoff for ipv6_skip_exthdr() retval Roel Kluin
@ 2008-04-21 12:24   ` Patrick McHardy
  0 siblings, 0 replies; 10+ messages in thread
From: Patrick McHardy @ 2008-04-21 12:24 UTC (permalink / raw)
  To: Roel Kluin; +Cc: Jan Engelhardt, coreteam, netfilter, netfilter-devel, lkml

Roel Kluin wrote:
> if tcphoff remains unsigned, a negative ipv6_skip_exthdr() return value will
> go unnoticed,

Applied, thanks.

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

end of thread, other threads:[~2008-04-21 12:24 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-04-16  1:39 [PATCH 1/6] MIPS: irixelf: fix test unsigned var < 0 Roel Kluin
2008-04-16 15:27 ` Roel Kluin
2008-04-16 15:32   ` [PATCH 4/6] RTC: rtc-ds1374: fix unsigned new_alarm test Roel Kluin
2008-04-18 21:58     ` Alessandro Zummo
2008-04-16 16:00 ` [PATCH 5/6] NETFILTER: signed tcphoff for ipv6_skip_exthdr() retval Roel Kluin
2008-04-21 12:24   ` [netfilter-core] " Patrick McHardy
2008-04-16 16:20 ` [PATCH 6/6] sound/drivers/dummy.c: fix negative snd_pcm_format_width() check Roel Kluin
2008-04-16 16:31   ` [alsa-devel] " Takashi Iwai
2008-04-16 18:00 ` [PATCH 1/6] MIPS: irixelf: fix test unsigned var < 0 Ralf Baechle
2008-04-16 19:39 ` Marcin Slusarz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox