Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1476415 > unrolled thread
| Started by | Pavel Andrianov <andrianov@ispras.ru> |
|---|---|
| First post | 2016-09-05 15:20 +0200 |
| Last post | 2016-09-06 05:40 +0200 |
| Articles | 3 — 3 participants |
Back to article view | Back to linux.kernel
[PATCH] speakup: Add spinlock in synth_direct_store Pavel Andrianov <andrianov@ispras.ru> - 2016-09-05 15:20 +0200
Re: [PATCH] speakup: Add spinlock in synth_direct_store Samuel Thibault <samuel.thibault@ens-lyon.org> - 2016-09-06 00:10 +0200
Re: [PATCH] speakup: Add spinlock in synth_direct_store Vaishali Thakkar <vaishali.thakkar@oracle.com> - 2016-09-06 05:40 +0200
| From | Pavel Andrianov <andrianov@ispras.ru> |
|---|---|
| Date | 2016-09-05 15:20 +0200 |
| Subject | [PATCH] speakup: Add spinlock in synth_direct_store |
| Message-ID | <se1YC-4eB-35@gated-at.bofh.it> |
All operations with synth buffer should be protected,
as there are global pointers, which should be modified atomically.
Found by Linux Driver Verification project (linuxtesting.org)
Signed-off-by: Pavel Andrianov <andrianov@ispras.ru>
---
drivers/staging/speakup/kobjects.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/staging/speakup/kobjects.c b/drivers/staging/speakup/kobjects.c
index 528cbdc..7fedee3 100644
--- a/drivers/staging/speakup/kobjects.c
+++ b/drivers/staging/speakup/kobjects.c
@@ -411,11 +411,13 @@ static ssize_t synth_direct_store(struct kobject *kobj,
int len;
int bytes;
const char *ptr = buf;
+ unsigned long flags;
if (!synth)
return -EPERM;
len = strlen(buf);
+ spin_lock_irqsave(&speakup_info.spinlock, flags);
while (len > 0) {
bytes = min_t(size_t, len, 250);
strncpy(tmp, ptr, bytes);
@@ -425,6 +427,7 @@ static ssize_t synth_direct_store(struct kobject *kobj,
ptr += bytes;
len -= bytes;
}
+ spin_unlock_irqrestore(&speakup_info.spinlock, flags);
return count;
}
--
2.7.4
[toc] | [next] | [standalone]
| From | Samuel Thibault <samuel.thibault@ens-lyon.org> |
|---|---|
| Date | 2016-09-06 00:10 +0200 |
| Message-ID | <seafw-1ol-11@gated-at.bofh.it> |
| In reply to | #1476415 |
Pavel Andrianov, on Mon 05 Sep 2016 16:17:47 +0300, wrote:
> All operations with synth buffer should be protected,
> as there are global pointers, which should be modified atomically.
>
> Found by Linux Driver Verification project (linuxtesting.org)
>
> Signed-off-by: Pavel Andrianov <andrianov@ispras.ru>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
> ---
> drivers/staging/speakup/kobjects.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/staging/speakup/kobjects.c b/drivers/staging/speakup/kobjects.c
> index 528cbdc..7fedee3 100644
> --- a/drivers/staging/speakup/kobjects.c
> +++ b/drivers/staging/speakup/kobjects.c
> @@ -411,11 +411,13 @@ static ssize_t synth_direct_store(struct kobject *kobj,
> int len;
> int bytes;
> const char *ptr = buf;
> + unsigned long flags;
>
> if (!synth)
> return -EPERM;
>
> len = strlen(buf);
> + spin_lock_irqsave(&speakup_info.spinlock, flags);
> while (len > 0) {
> bytes = min_t(size_t, len, 250);
> strncpy(tmp, ptr, bytes);
> @@ -425,6 +427,7 @@ static ssize_t synth_direct_store(struct kobject *kobj,
> ptr += bytes;
> len -= bytes;
> }
> + spin_unlock_irqrestore(&speakup_info.spinlock, flags);
> return count;
> }
>
> --
> 2.7.4
>
--
Samuel
Linux, c'est simple : ça s'adresse à une machine qui est parfois un peu
maraboutée mais qui d'habitude n'a pas d'états d'âme. Sur Usenet y'a
plein d'humains et de primates, et ça devient vraiment gore par moment.
-+- TP in : Guide du linuxien pervers - "Le linuxien a-t-il une âme ?" -+-
[toc] | [prev] | [next] | [standalone]
| From | Vaishali Thakkar <vaishali.thakkar@oracle.com> |
|---|---|
| Date | 2016-09-06 05:40 +0200 |
| Message-ID | <sefoR-4Nx-3@gated-at.bofh.it> |
| In reply to | #1476415 |
On Monday 05 September 2016 06:47 PM, Pavel Andrianov wrote:
> All operations with synth buffer should be protected,
> as there are global pointers, which should be modified atomically.
>
> Found by Linux Driver Verification project (linuxtesting.org)
>
> Signed-off-by: Pavel Andrianov <andrianov@ispras.ru>
Acked-by: Vaishali Thakkar <vaishali.thakkar@oracle.com>
> ---
> drivers/staging/speakup/kobjects.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/staging/speakup/kobjects.c b/drivers/staging/speakup/kobjects.c
> index 528cbdc..7fedee3 100644
> --- a/drivers/staging/speakup/kobjects.c
> +++ b/drivers/staging/speakup/kobjects.c
> @@ -411,11 +411,13 @@ static ssize_t synth_direct_store(struct kobject *kobj,
> int len;
> int bytes;
> const char *ptr = buf;
> + unsigned long flags;
>
> if (!synth)
> return -EPERM;
>
> len = strlen(buf);
> + spin_lock_irqsave(&speakup_info.spinlock, flags);
> while (len > 0) {
> bytes = min_t(size_t, len, 250);
> strncpy(tmp, ptr, bytes);
> @@ -425,6 +427,7 @@ static ssize_t synth_direct_store(struct kobject *kobj,
> ptr += bytes;
> len -= bytes;
> }
> + spin_unlock_irqrestore(&speakup_info.spinlock, flags);
> return count;
> }
>
>
--
Vaishali
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web