Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1724644 > unrolled thread
| Started by | Kees Cook <keescook@chromium.org> |
|---|---|
| First post | 2017-09-01 01:40 +0200 |
| Last post | 2017-09-01 20:00 +0200 |
| Articles | 5 — 3 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[PATCH 26/31] staging/comedi/das16: Make timer initialization unconditional Kees Cook <keescook@chromium.org> - 2017-09-01 01:40 +0200
Re: [PATCH 26/31] staging/comedi/das16: Make timer initialization unconditional Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-09-01 07:10 +0200
Re: [PATCH 26/31] staging/comedi/das16: Make timer initialization unconditional Ian Abbott <abbotti@mev.co.uk> - 2017-09-01 11:40 +0200
Re: [PATCH 26/31] staging/comedi/das16: Make timer initialization unconditional Ian Abbott <abbotti@mev.co.uk> - 2017-09-01 11:40 +0200
Re: [PATCH 26/31] staging/comedi/das16: Make timer initialization unconditional Kees Cook <keescook@chromium.org> - 2017-09-01 20:00 +0200
| From | Kees Cook <keescook@chromium.org> |
|---|---|
| Date | 2017-09-01 01:40 +0200 |
| Subject | [PATCH 26/31] staging/comedi/das16: Make timer initialization unconditional |
| Message-ID | <ukHe1-3XZ-1@gated-at.bofh.it> |
With timer initialization made unconditional, there is no reason to
make del_timer_sync() calls conditionally, there by removing the test
of the .data field.
Cc: Ian Abbott <abbotti@mev.co.uk>
Cc: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: devel@driverdev.osuosl.org
Signed-off-by: Kees Cook <keescook@chromium.org>
---
drivers/staging/comedi/drivers/das16.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/drivers/staging/comedi/drivers/das16.c b/drivers/staging/comedi/drivers/das16.c
index 5d157951f63f..4514179b2007 100644
--- a/drivers/staging/comedi/drivers/das16.c
+++ b/drivers/staging/comedi/drivers/das16.c
@@ -941,10 +941,8 @@ static void das16_alloc_dma(struct comedi_device *dev, unsigned int dma_chan)
/* DMA uses two buffers */
devpriv->dma = comedi_isadma_alloc(dev, 2, dma_chan, dma_chan,
DAS16_DMA_SIZE, COMEDI_ISADMA_READ);
- if (devpriv->dma) {
- setup_timer(&devpriv->timer, das16_timer_interrupt,
- (unsigned long)dev);
- }
+ setup_timer(&devpriv->timer, das16_timer_interrupt,
+ (unsigned long)dev);
}
static void das16_free_dma(struct comedi_device *dev)
@@ -952,8 +950,7 @@ static void das16_free_dma(struct comedi_device *dev)
struct das16_private_struct *devpriv = dev->private;
if (devpriv) {
- if (devpriv->timer.data)
- del_timer_sync(&devpriv->timer);
+ del_timer_sync(&devpriv->timer);
comedi_isadma_free(devpriv->dma);
}
}
--
2.7.4
[toc] | [next] | [standalone]
| From | Greg Kroah-Hartman <gregkh@linuxfoundation.org> |
|---|---|
| Date | 2017-09-01 07:10 +0200 |
| Subject | Re: [PATCH 26/31] staging/comedi/das16: Make timer initialization unconditional |
| Message-ID | <ukMnp-7GJ-25@gated-at.bofh.it> |
| In reply to | #1724644 |
On Thu, Aug 31, 2017 at 04:29:38PM -0700, Kees Cook wrote: > With timer initialization made unconditional, there is no reason to > make del_timer_sync() calls conditionally, there by removing the test > of the .data field. > > Cc: Ian Abbott <abbotti@mev.co.uk> > Cc: H Hartley Sweeten <hsweeten@visionengravers.com> > Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> > Cc: devel@driverdev.osuosl.org > Signed-off-by: Kees Cook <keescook@chromium.org> > --- > drivers/staging/comedi/drivers/das16.c | 9 +++------ > 1 file changed, 3 insertions(+), 6 deletions(-) Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
[toc] | [prev] | [next] | [standalone]
| From | Ian Abbott <abbotti@mev.co.uk> |
|---|---|
| Date | 2017-09-01 11:40 +0200 |
| Subject | Re: [PATCH 26/31] staging/comedi/das16: Make timer initialization unconditional |
| Message-ID | <ukQAF-21R-13@gated-at.bofh.it> |
| In reply to | #1724644 |
On 01/09/17 00:29, Kees Cook wrote:
> With timer initialization made unconditional, there is no reason to
> make del_timer_sync() calls conditionally, there by removing the test
> of the .data field.
>
> Cc: Ian Abbott <abbotti@mev.co.uk>
> Cc: H Hartley Sweeten <hsweeten@visionengravers.com>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: devel@driverdev.osuosl.org
> Signed-off-by: Kees Cook <keescook@chromium.org>
> ---
> drivers/staging/comedi/drivers/das16.c | 9 +++------
> 1 file changed, 3 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/staging/comedi/drivers/das16.c b/drivers/staging/comedi/drivers/das16.c
> index 5d157951f63f..4514179b2007 100644
> --- a/drivers/staging/comedi/drivers/das16.c
> +++ b/drivers/staging/comedi/drivers/das16.c
> @@ -941,10 +941,8 @@ static void das16_alloc_dma(struct comedi_device *dev, unsigned int dma_chan)
> /* DMA uses two buffers */
> devpriv->dma = comedi_isadma_alloc(dev, 2, dma_chan, dma_chan,
> DAS16_DMA_SIZE, COMEDI_ISADMA_READ);
> - if (devpriv->dma) {
> - setup_timer(&devpriv->timer, das16_timer_interrupt,
> - (unsigned long)dev);
> - }
> + setup_timer(&devpriv->timer, das16_timer_interrupt,
> + (unsigned long)dev);
> }
das16_alloc_dma() returns before the call to comedi_isadma_alloc() if
the dma_chan parameter is not one of the values 1 or 3, so setup_timer()
will not be called in that case.
>
> static void das16_free_dma(struct comedi_device *dev)
> @@ -952,8 +950,7 @@ static void das16_free_dma(struct comedi_device *dev)
> struct das16_private_struct *devpriv = dev->private;
>
> if (devpriv) {
> - if (devpriv->timer.data)
> - del_timer_sync(&devpriv->timer);
> + del_timer_sync(&devpriv->timer);
If setup_timer() has not been called (see remark above), this change
will break.
> comedi_isadma_free(devpriv->dma);
> }
> }
>
--
-=( Ian Abbott @ MEV Ltd. E-mail: <abbotti@mev.co.uk> )=-
-=( Web: http://www.mev.co.uk/ )=-
[toc] | [prev] | [next] | [standalone]
| From | Ian Abbott <abbotti@mev.co.uk> |
|---|---|
| Date | 2017-09-01 11:40 +0200 |
| Subject | Re: [PATCH 26/31] staging/comedi/das16: Make timer initialization unconditional |
| Message-ID | <ukQAG-21R-31@gated-at.bofh.it> |
| In reply to | #1724909 |
On 01/09/17 10:29, Ian Abbott wrote:
> On 01/09/17 00:29, Kees Cook wrote:
>> With timer initialization made unconditional, there is no reason to
>> make del_timer_sync() calls conditionally, there by removing the test
>> of the .data field.
>>
>> Cc: Ian Abbott <abbotti@mev.co.uk>
>> Cc: H Hartley Sweeten <hsweeten@visionengravers.com>
>> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
>> Cc: devel@driverdev.osuosl.org
>> Signed-off-by: Kees Cook <keescook@chromium.org>
>> ---
>> drivers/staging/comedi/drivers/das16.c | 9 +++------
>> 1 file changed, 3 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/staging/comedi/drivers/das16.c
>> b/drivers/staging/comedi/drivers/das16.c
>> index 5d157951f63f..4514179b2007 100644
>> --- a/drivers/staging/comedi/drivers/das16.c
>> +++ b/drivers/staging/comedi/drivers/das16.c
>> @@ -941,10 +941,8 @@ static void das16_alloc_dma(struct comedi_device
>> *dev, unsigned int dma_chan)
>> /* DMA uses two buffers */
>> devpriv->dma = comedi_isadma_alloc(dev, 2, dma_chan, dma_chan,
>> DAS16_DMA_SIZE, COMEDI_ISADMA_READ);
>> - if (devpriv->dma) {
>> - setup_timer(&devpriv->timer, das16_timer_interrupt,
>> - (unsigned long)dev);
>> - }
>> + setup_timer(&devpriv->timer, das16_timer_interrupt,
>> + (unsigned long)dev);
>> }
>
> das16_alloc_dma() returns before the call to comedi_isadma_alloc() if
> the dma_chan parameter is not one of the values 1 or 3, so setup_timer()
> will not be called in that case.
>
>> static void das16_free_dma(struct comedi_device *dev)
>> @@ -952,8 +950,7 @@ static void das16_free_dma(struct comedi_device *dev)
>> struct das16_private_struct *devpriv = dev->private;
>> if (devpriv) {
>> - if (devpriv->timer.data)
>> - del_timer_sync(&devpriv->timer);
>> + del_timer_sync(&devpriv->timer);
>
> If setup_timer() has not been called (see remark above), this change
> will break.
>
>> comedi_isadma_free(devpriv->dma);
>> }
>> }
>>
If you want to avoid testing devpriv->timer.data for some reason, you
could make the calls to setup_timer() and del_timer_sync() depend on
devpriv->dma.
--
-=( Ian Abbott @ MEV Ltd. E-mail: <abbotti@mev.co.uk> )=-
-=( Web: http://www.mev.co.uk/ )=-
[toc] | [prev] | [next] | [standalone]
| From | Kees Cook <keescook@chromium.org> |
|---|---|
| Date | 2017-09-01 20:00 +0200 |
| Message-ID | <ukYoy-8lL-5@gated-at.bofh.it> |
| In reply to | #1724916 |
On Fri, Sep 1, 2017 at 2:38 AM, Ian Abbott <abbotti@mev.co.uk> wrote:
> On 01/09/17 10:29, Ian Abbott wrote:
>>
>> On 01/09/17 00:29, Kees Cook wrote:
>>>
>>> With timer initialization made unconditional, there is no reason to
>>> make del_timer_sync() calls conditionally, there by removing the test
>>> of the .data field.
>>>
>>> Cc: Ian Abbott <abbotti@mev.co.uk>
>>> Cc: H Hartley Sweeten <hsweeten@visionengravers.com>
>>> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
>>> Cc: devel@driverdev.osuosl.org
>>> Signed-off-by: Kees Cook <keescook@chromium.org>
>>> ---
>>> drivers/staging/comedi/drivers/das16.c | 9 +++------
>>> 1 file changed, 3 insertions(+), 6 deletions(-)
>>>
>>> diff --git a/drivers/staging/comedi/drivers/das16.c
>>> b/drivers/staging/comedi/drivers/das16.c
>>> index 5d157951f63f..4514179b2007 100644
>>> --- a/drivers/staging/comedi/drivers/das16.c
>>> +++ b/drivers/staging/comedi/drivers/das16.c
>>> @@ -941,10 +941,8 @@ static void das16_alloc_dma(struct comedi_device
>>> *dev, unsigned int dma_chan)
>>> /* DMA uses two buffers */
>>> devpriv->dma = comedi_isadma_alloc(dev, 2, dma_chan, dma_chan,
>>> DAS16_DMA_SIZE, COMEDI_ISADMA_READ);
>>> - if (devpriv->dma) {
>>> - setup_timer(&devpriv->timer, das16_timer_interrupt,
>>> - (unsigned long)dev);
>>> - }
>>> + setup_timer(&devpriv->timer, das16_timer_interrupt,
>>> + (unsigned long)dev);
>>> }
>>
>>
>> das16_alloc_dma() returns before the call to comedi_isadma_alloc() if the
>> dma_chan parameter is not one of the values 1 or 3, so setup_timer() will
>> not be called in that case.
>>
>>> static void das16_free_dma(struct comedi_device *dev)
>>> @@ -952,8 +950,7 @@ static void das16_free_dma(struct comedi_device *dev)
>>> struct das16_private_struct *devpriv = dev->private;
>>> if (devpriv) {
>>> - if (devpriv->timer.data)
>>> - del_timer_sync(&devpriv->timer);
>>> + del_timer_sync(&devpriv->timer);
>>
>>
>> If setup_timer() has not been called (see remark above), this change will
>> break.
>>
>>> comedi_isadma_free(devpriv->dma);
>>> }
>>> }
>>>
>
> If you want to avoid testing devpriv->timer.data for some reason, you could
> make the calls to setup_timer() and del_timer_sync() depend on devpriv->dma.
Thanks for checking this! I think the cleanest would be to just move
setup_timer() to the start of das16_alloc_dma(). I'll make that
adjustment.
-Kees
--
Kees Cook
Pixel Security
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web