mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* Re: [PATCH] drivers/staging/speakup: avoid out-of-range access
       [not found] <1357413465-42357-1-git-send-email-nickolai@csail.mit.edu>
@ 2013-01-05 19:29 ` Samuel Thibault
  2013-01-07 17:44   ` Greg KH
  0 siblings, 1 reply; 3+ messages in thread
From: Samuel Thibault @ 2013-01-05 19:29 UTC (permalink / raw)
  To: Nickolai Zeldovich, gregkh
  Cc: William Hubbs, Chris Brannon, Kirk Reiser, linux-kernel, speakup

Indeed. The same happens in synth_add, so Greg please use this instead:


Check that array index is in-bounds before accessing the synths[] array.

Signed-off-by: Nickolai Zeldovich <nickolai@csail.mit.edu>
Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>

---
 drivers/staging/speakup/synth.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/speakup/synth.c b/drivers/staging/speakup/synth.c
index df95337..b91d22b 100644
--- a/drivers/staging/speakup/synth.c
+++ b/drivers/staging/speakup/synth.c
@@ -342,7 +342,7 @@ int synth_init(char *synth_name)
 
 	mutex_lock(&spk_mutex);
 	/* First, check if we already have it loaded. */
-	for (i = 0; synths[i] != NULL && i < MAXSYNTHS; i++)
+	for (i = 0; i < MAXSYNTHS && synths[i] != NULL; i++)
 		if (strcmp(synths[i]->name, synth_name) == 0)
 			synth = synths[i];
 
@@ -423,7 +423,7 @@ int synth_add(struct spk_synth *in_synth
 	int i;
 	int status = 0;
 	mutex_lock(&spk_mutex);
-	for (i = 0; synths[i] != NULL && i < MAXSYNTHS; i++)
+	for (i = 0; i < MAXSYNTHS && synths[i] != NULL; i++)
 		/* synth_remove() is responsible for rotating the array down */
 		if (in_synth == synths[i]) {
 			mutex_unlock(&spk_mutex);

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

* Re: [PATCH] drivers/staging/speakup: avoid out-of-range access
  2013-01-05 19:29 ` [PATCH] drivers/staging/speakup: avoid out-of-range access Samuel Thibault
@ 2013-01-07 17:44   ` Greg KH
  2013-01-07 21:03     ` Samuel Thibault
  0 siblings, 1 reply; 3+ messages in thread
From: Greg KH @ 2013-01-07 17:44 UTC (permalink / raw)
  To: Samuel Thibault, Nickolai Zeldovich, William Hubbs,
	Chris Brannon, Kirk Reiser, linux-kernel, speakup

On Sat, Jan 05, 2013 at 08:29:44PM +0100, Samuel Thibault wrote:
> Indeed. The same happens in synth_add, so Greg please use this instead:
> 
> 
> Check that array index is in-bounds before accessing the synths[] array.
> 
> Signed-off-by: Nickolai Zeldovich <nickolai@csail.mit.edu>
> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>

Wait, Nickolai wrote the first patch, so how could he sign off on your
patch?  How about sending me an add-on patch on top of the first one
which adds the additional check?  That way I'll apply both of them and
everyone will get the proper credit?

thanks,

greg k-h

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

* Re: [PATCH] drivers/staging/speakup: avoid out-of-range access
  2013-01-07 17:44   ` Greg KH
@ 2013-01-07 21:03     ` Samuel Thibault
  0 siblings, 0 replies; 3+ messages in thread
From: Samuel Thibault @ 2013-01-07 21:03 UTC (permalink / raw)
  To: Greg KH
  Cc: Nickolai Zeldovich, William Hubbs, Chris Brannon, Kirk Reiser,
	linux-kernel, speakup

Greg KH, le Mon 07 Jan 2013 09:44:53 -0800, a écrit :
> Wait, Nickolai wrote the first patch, so how could he sign off on your
> patch?  How about sending me an add-on patch on top of the first one
> which adds the additional check?

Right, here it is:


Check that array index is in-bounds before accessing the synths[] array.

Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>

---
 drivers/staging/speakup/synth.c |    2 +-
 1 file changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/speakup/synth.c b/drivers/staging/speakup/synth.c
index df95337..b91d22b 100644
--- a/drivers/staging/speakup/synth.c
+++ b/drivers/staging/speakup/synth.c
@@ -423,7 +423,7 @@ int synth_add(struct spk_synth *in_synth
 	int i;
 	int status = 0;
 	mutex_lock(&spk_mutex);
-	for (i = 0; synths[i] != NULL && i < MAXSYNTHS; i++)
+	for (i = 0; i < MAXSYNTHS && synths[i] != NULL; i++)
 		/* synth_remove() is responsible for rotating the array down */
 		if (in_synth == synths[i]) {
 			mutex_unlock(&spk_mutex);

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

end of thread, other threads:[~2013-01-07 21:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <1357413465-42357-1-git-send-email-nickolai@csail.mit.edu>
2013-01-05 19:29 ` [PATCH] drivers/staging/speakup: avoid out-of-range access Samuel Thibault
2013-01-07 17:44   ` Greg KH
2013-01-07 21:03     ` Samuel Thibault

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

all inboxes | Powered by JetHome®