public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* drivers/gpu/drm/radeon/r600_blit.c: fix possible NULL pointer derefernce
@ 2010-07-19 21:42 Alexander Y. Fomichev
  2010-07-20 17:37 ` Alex Deucher
  0 siblings, 1 reply; 8+ messages in thread
From: Alexander Y. Fomichev @ 2010-07-19 21:42 UTC (permalink / raw)
  To: Dave Airlie, Alex Deucher, Robert Noland, Matt Turner,
	Jerome Glisse, akpm, dri-devel, linux-kernel

This patch fix possible NULL pointer dereference when
r600_prepare_blit_copy tries to fill dev_priv->blit_vb->file_priv
without check of dev_priv->blit_vb. dev_priv->blit_vb should be
filled by r600_nomm_get_vb but latest can fail with EAGAIN.
Addresses: https://bugzilla.kernel.org/show_bug.cgi?id=16375

---
 drivers/gpu/drm/radeon/r600_blit.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/drivers/gpu/drm/radeon/r600_blit.c b/drivers/gpu/drm/radeon/r600_blit.c
index f4fb88e..0df4a2b 100644
--- a/drivers/gpu/drm/radeon/r600_blit.c
+++ b/drivers/gpu/drm/radeon/r600_blit.c
@@ -541,6 +541,8 @@ r600_prepare_blit_copy(struct drm_device *dev, struct drm_file *file_priv)
        DRM_DEBUG("\n");

        r600_nomm_get_vb(dev);
+       if (!dev_priv->blit_vb)
+               return;

        dev_priv->blit_vb->file_priv = file_priv;

--
1.7.1.1

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

* Re: drivers/gpu/drm/radeon/r600_blit.c: fix possible NULL pointer  derefernce
  2010-07-19 21:42 drivers/gpu/drm/radeon/r600_blit.c: fix possible NULL pointer derefernce Alexander Y. Fomichev
@ 2010-07-20 17:37 ` Alex Deucher
  2010-07-20 20:13   ` Alexander Y. Fomichev
  0 siblings, 1 reply; 8+ messages in thread
From: Alex Deucher @ 2010-07-20 17:37 UTC (permalink / raw)
  To: Alexander Y. Fomichev
  Cc: Dave Airlie, Robert Noland, Matt Turner, Jerome Glisse, akpm,
	dri-devel, linux-kernel

On Mon, Jul 19, 2010 at 5:42 PM, Alexander Y. Fomichev
<git.user@gmail.com> wrote:
> This patch fix possible NULL pointer dereference when
> r600_prepare_blit_copy tries to fill dev_priv->blit_vb->file_priv
> without check of dev_priv->blit_vb. dev_priv->blit_vb should be
> filled by r600_nomm_get_vb but latest can fail with EAGAIN.
> Addresses: https://bugzilla.kernel.org/show_bug.cgi?id=16375
>
> ---
>  drivers/gpu/drm/radeon/r600_blit.c |    2 ++
>  1 files changed, 2 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/gpu/drm/radeon/r600_blit.c b/drivers/gpu/drm/radeon/r600_blit.c
> index f4fb88e..0df4a2b 100644
> --- a/drivers/gpu/drm/radeon/r600_blit.c
> +++ b/drivers/gpu/drm/radeon/r600_blit.c
> @@ -541,6 +541,8 @@ r600_prepare_blit_copy(struct drm_device *dev, struct drm_file *file_priv)
>        DRM_DEBUG("\n");
>
>        r600_nomm_get_vb(dev);
> +       if (!dev_priv->blit_vb)
> +               return;

r600_prepare_blit_copy returns an int so something like this would be better:
--- a/drivers/gpu/drm/radeon/r600_blit.c
+++ b/drivers/gpu/drm/radeon/r600_blit.c
@@ -539,8 +539,10 @@ r600_prepare_blit_copy(struct drm_device *dev,
struct drm_file *file_priv)
 {
        drm_radeon_private_t *dev_priv = dev->dev_private;
        DRM_DEBUG("\n");
+       int ret = r600_nomm_get_vb(dev);

-       r600_nomm_get_vb(dev);
+       if (ret)
+               return ret;

        dev_priv->blit_vb->file_priv = file_priv;


Alex

>
>        dev_priv->blit_vb->file_priv = file_priv;
>
> --
> 1.7.1.1
>

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

* Re: drivers/gpu/drm/radeon/r600_blit.c: fix possible NULL pointer  derefernce
  2010-07-20 17:37 ` Alex Deucher
@ 2010-07-20 20:13   ` Alexander Y. Fomichev
  2010-07-20 21:00     ` Alex Deucher
  0 siblings, 1 reply; 8+ messages in thread
From: Alexander Y. Fomichev @ 2010-07-20 20:13 UTC (permalink / raw)
  To: Alex Deucher
  Cc: Dave Airlie, Robert Noland, Matt Turner, Jerome Glisse, akpm,
	dri-devel, linux-kernel

On Tue, Jul 20, 2010 at 9:37 PM, Alex Deucher <alexdeucher@gmail.com> wrote:
> On Mon, Jul 19, 2010 at 5:42 PM, Alexander Y. Fomichev
> <git.user@gmail.com> wrote:
>> This patch fix possible NULL pointer dereference when
>> r600_prepare_blit_copy tries to fill dev_priv->blit_vb->file_priv
>> without check of dev_priv->blit_vb. dev_priv->blit_vb should be
>> filled by r600_nomm_get_vb but latest can fail with EAGAIN.
>> Addresses: https://bugzilla.kernel.org/show_bug.cgi?id=16375
>>
>> ---
>>  drivers/gpu/drm/radeon/r600_blit.c |    2 ++
>>  1 files changed, 2 insertions(+), 0 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/radeon/r600_blit.c b/drivers/gpu/drm/radeon/r600_blit.c
>> index f4fb88e..0df4a2b 100644
>> --- a/drivers/gpu/drm/radeon/r600_blit.c
>> +++ b/drivers/gpu/drm/radeon/r600_blit.c
>> @@ -541,6 +541,8 @@ r600_prepare_blit_copy(struct drm_device *dev, struct drm_file *file_priv)
>>        DRM_DEBUG("\n");
>>
>>        r600_nomm_get_vb(dev);
>> +       if (!dev_priv->blit_vb)
>> +               return;
>
> r600_prepare_blit_copy returns an int so something like this would be better:
> --- a/drivers/gpu/drm/radeon/r600_blit.c
> +++ b/drivers/gpu/drm/radeon/r600_blit.c
> @@ -539,8 +539,10 @@ r600_prepare_blit_copy(struct drm_device *dev,
> struct drm_file *file_priv)
>  {
>        drm_radeon_private_t *dev_priv = dev->dev_private;
>        DRM_DEBUG("\n");
> +       int ret = r600_nomm_get_vb(dev);
>
> -       r600_nomm_get_vb(dev);
> +       if (ret)
> +               return ret;
>
>        dev_priv->blit_vb->file_priv = file_priv;
>
>
> Alex
>
>>
>>        dev_priv->blit_vb->file_priv = file_priv;
>>
>> --
>> 1.7.1.1
>>
>

i haven't any preferneces, the only thing is - it would be logical
to have every check in common style, so other cases
(r600_blit_copy, r600_blit_swap) should be fixed, nop?

-- 
Best regards.
       Alexander Y. Fomichev <git.user@gmail.com>

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

* Re: drivers/gpu/drm/radeon/r600_blit.c: fix possible NULL pointer  derefernce
  2010-07-20 20:13   ` Alexander Y. Fomichev
@ 2010-07-20 21:00     ` Alex Deucher
  2010-07-20 21:07       ` Alexander Y. Fomichev
  0 siblings, 1 reply; 8+ messages in thread
From: Alex Deucher @ 2010-07-20 21:00 UTC (permalink / raw)
  To: Alexander Y. Fomichev
  Cc: Dave Airlie, Robert Noland, Matt Turner, Jerome Glisse, akpm,
	dri-devel, linux-kernel

On Tue, Jul 20, 2010 at 4:13 PM, Alexander Y. Fomichev
<git.user@gmail.com> wrote:
> On Tue, Jul 20, 2010 at 9:37 PM, Alex Deucher <alexdeucher@gmail.com> wrote:
>> On Mon, Jul 19, 2010 at 5:42 PM, Alexander Y. Fomichev
>> <git.user@gmail.com> wrote:
>>> This patch fix possible NULL pointer dereference when
>>> r600_prepare_blit_copy tries to fill dev_priv->blit_vb->file_priv
>>> without check of dev_priv->blit_vb. dev_priv->blit_vb should be
>>> filled by r600_nomm_get_vb but latest can fail with EAGAIN.
>>> Addresses: https://bugzilla.kernel.org/show_bug.cgi?id=16375
>>>
>>> ---
>>>  drivers/gpu/drm/radeon/r600_blit.c |    2 ++
>>>  1 files changed, 2 insertions(+), 0 deletions(-)
>>>
>>> diff --git a/drivers/gpu/drm/radeon/r600_blit.c b/drivers/gpu/drm/radeon/r600_blit.c
>>> index f4fb88e..0df4a2b 100644
>>> --- a/drivers/gpu/drm/radeon/r600_blit.c
>>> +++ b/drivers/gpu/drm/radeon/r600_blit.c
>>> @@ -541,6 +541,8 @@ r600_prepare_blit_copy(struct drm_device *dev, struct drm_file *file_priv)
>>>        DRM_DEBUG("\n");
>>>
>>>        r600_nomm_get_vb(dev);
>>> +       if (!dev_priv->blit_vb)
>>> +               return;
>>
>> r600_prepare_blit_copy returns an int so something like this would be better:
>> --- a/drivers/gpu/drm/radeon/r600_blit.c
>> +++ b/drivers/gpu/drm/radeon/r600_blit.c
>> @@ -539,8 +539,10 @@ r600_prepare_blit_copy(struct drm_device *dev,
>> struct drm_file *file_priv)
>>  {
>>        drm_radeon_private_t *dev_priv = dev->dev_private;
>>        DRM_DEBUG("\n");
>> +       int ret = r600_nomm_get_vb(dev);
>>
>> -       r600_nomm_get_vb(dev);
>> +       if (ret)
>> +               return ret;
>>
>>        dev_priv->blit_vb->file_priv = file_priv;
>>
>>
>> Alex
>>
>>>
>>>        dev_priv->blit_vb->file_priv = file_priv;
>>>
>>> --
>>> 1.7.1.1
>>>
>>
>
> i haven't any preferneces, the only thing is - it would be logical
> to have every check in common style, so other cases
> (r600_blit_copy, r600_blit_swap) should be fixed, nop?

Those are void functions so there's nothing to return.

Alex

>
> --
> Best regards.
>        Alexander Y. Fomichev <git.user@gmail.com>
>

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

* Re: drivers/gpu/drm/radeon/r600_blit.c: fix possible NULL pointer  derefernce
  2010-07-20 21:00     ` Alex Deucher
@ 2010-07-20 21:07       ` Alexander Y. Fomichev
  2010-07-20 21:29         ` Alex Deucher
  2010-07-21  0:30         ` Dave Airlie
  0 siblings, 2 replies; 8+ messages in thread
From: Alexander Y. Fomichev @ 2010-07-20 21:07 UTC (permalink / raw)
  To: Alex Deucher
  Cc: Dave Airlie, Robert Noland, Matt Turner, Jerome Glisse, akpm,
	dri-devel, linux-kernel

On Wed, Jul 21, 2010 at 1:00 AM, Alex Deucher <alexdeucher@gmail.com> wrote:
> On Tue, Jul 20, 2010 at 4:13 PM, Alexander Y. Fomichev
> <git.user@gmail.com> wrote:
>> On Tue, Jul 20, 2010 at 9:37 PM, Alex Deucher <alexdeucher@gmail.com> wrote:
>>> On Mon, Jul 19, 2010 at 5:42 PM, Alexander Y. Fomichev
>>> <git.user@gmail.com> wrote:
>>>> This patch fix possible NULL pointer dereference when
>>>> r600_prepare_blit_copy tries to fill dev_priv->blit_vb->file_priv
>>>> without check of dev_priv->blit_vb. dev_priv->blit_vb should be
>>>> filled by r600_nomm_get_vb but latest can fail with EAGAIN.
>>>> Addresses: https://bugzilla.kernel.org/show_bug.cgi?id=16375
>>>>
>>>> ---
>>>>  drivers/gpu/drm/radeon/r600_blit.c |    2 ++
>>>>  1 files changed, 2 insertions(+), 0 deletions(-)
>>>>
>>>> diff --git a/drivers/gpu/drm/radeon/r600_blit.c b/drivers/gpu/drm/radeon/r600_blit.c
>>>> index f4fb88e..0df4a2b 100644
>>>> --- a/drivers/gpu/drm/radeon/r600_blit.c
>>>> +++ b/drivers/gpu/drm/radeon/r600_blit.c
>>>> @@ -541,6 +541,8 @@ r600_prepare_blit_copy(struct drm_device *dev, struct drm_file *file_priv)
>>>>        DRM_DEBUG("\n");
>>>>
>>>>        r600_nomm_get_vb(dev);
>>>> +       if (!dev_priv->blit_vb)
>>>> +               return;
>>>
>>> r600_prepare_blit_copy returns an int so something like this would be better:
>>> --- a/drivers/gpu/drm/radeon/r600_blit.c
>>> +++ b/drivers/gpu/drm/radeon/r600_blit.c
>>> @@ -539,8 +539,10 @@ r600_prepare_blit_copy(struct drm_device *dev,
>>> struct drm_file *file_priv)
>>>  {
>>>        drm_radeon_private_t *dev_priv = dev->dev_private;
>>>        DRM_DEBUG("\n");
>>> +       int ret = r600_nomm_get_vb(dev);
>>>
>>> -       r600_nomm_get_vb(dev);
>>> +       if (ret)
>>> +               return ret;
>>>
>>>        dev_priv->blit_vb->file_priv = file_priv;
>>>
>>>
>>> Alex
>>>
>>>>
>>>>        dev_priv->blit_vb->file_priv = file_priv;
>>>>
>>>> --
>>>> 1.7.1.1
>>>>
>>>
>>
>> i haven't any preferneces, the only thing is - it would be logical
>> to have every check in common style, so other cases
>> (r600_blit_copy, r600_blit_swap) should be fixed, nop?
>
> Those are void functions so there's nothing to return.

i mean both of them call r600_nomm_get_vb and both of them
check if (!dev_priv->blit_vb), not return  value.I mean would be
logical to check it the same way everytime r600_nomm_get_vb
gets called.

> Alex
>
>>
>> --
>> Best regards.
>>        Alexander Y. Fomichev <git.user@gmail.com>
>>
>



-- 
Best regards.
       Alexander Y. Fomichev <git.user@gmail.com>

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

* Re: drivers/gpu/drm/radeon/r600_blit.c: fix possible NULL pointer  derefernce
  2010-07-20 21:07       ` Alexander Y. Fomichev
@ 2010-07-20 21:29         ` Alex Deucher
  2010-07-21  7:06           ` Alexander Y. Fomichev
  2010-07-21  0:30         ` Dave Airlie
  1 sibling, 1 reply; 8+ messages in thread
From: Alex Deucher @ 2010-07-20 21:29 UTC (permalink / raw)
  To: Alexander Y. Fomichev
  Cc: Dave Airlie, Robert Noland, Matt Turner, Jerome Glisse, akpm,
	dri-devel, linux-kernel

On Tue, Jul 20, 2010 at 5:07 PM, Alexander Y. Fomichev
<git.user@gmail.com> wrote:
> On Wed, Jul 21, 2010 at 1:00 AM, Alex Deucher <alexdeucher@gmail.com> wrote:
>> On Tue, Jul 20, 2010 at 4:13 PM, Alexander Y. Fomichev
>> <git.user@gmail.com> wrote:
>>> On Tue, Jul 20, 2010 at 9:37 PM, Alex Deucher <alexdeucher@gmail.com> wrote:
>>>> On Mon, Jul 19, 2010 at 5:42 PM, Alexander Y. Fomichev
>>>> <git.user@gmail.com> wrote:
>>>>> This patch fix possible NULL pointer dereference when
>>>>> r600_prepare_blit_copy tries to fill dev_priv->blit_vb->file_priv
>>>>> without check of dev_priv->blit_vb. dev_priv->blit_vb should be
>>>>> filled by r600_nomm_get_vb but latest can fail with EAGAIN.
>>>>> Addresses: https://bugzilla.kernel.org/show_bug.cgi?id=16375
>>>>>
>>>>> ---
>>>>>  drivers/gpu/drm/radeon/r600_blit.c |    2 ++
>>>>>  1 files changed, 2 insertions(+), 0 deletions(-)
>>>>>
>>>>> diff --git a/drivers/gpu/drm/radeon/r600_blit.c b/drivers/gpu/drm/radeon/r600_blit.c
>>>>> index f4fb88e..0df4a2b 100644
>>>>> --- a/drivers/gpu/drm/radeon/r600_blit.c
>>>>> +++ b/drivers/gpu/drm/radeon/r600_blit.c
>>>>> @@ -541,6 +541,8 @@ r600_prepare_blit_copy(struct drm_device *dev, struct drm_file *file_priv)
>>>>>        DRM_DEBUG("\n");
>>>>>
>>>>>        r600_nomm_get_vb(dev);
>>>>> +       if (!dev_priv->blit_vb)
>>>>> +               return;
>>>>
>>>> r600_prepare_blit_copy returns an int so something like this would be better:
>>>> --- a/drivers/gpu/drm/radeon/r600_blit.c
>>>> +++ b/drivers/gpu/drm/radeon/r600_blit.c
>>>> @@ -539,8 +539,10 @@ r600_prepare_blit_copy(struct drm_device *dev,
>>>> struct drm_file *file_priv)
>>>>  {
>>>>        drm_radeon_private_t *dev_priv = dev->dev_private;
>>>>        DRM_DEBUG("\n");
>>>> +       int ret = r600_nomm_get_vb(dev);
>>>>
>>>> -       r600_nomm_get_vb(dev);
>>>> +       if (ret)
>>>> +               return ret;
>>>>
>>>>        dev_priv->blit_vb->file_priv = file_priv;
>>>>
>>>>
>>>> Alex
>>>>
>>>>>
>>>>>        dev_priv->blit_vb->file_priv = file_priv;
>>>>>
>>>>> --
>>>>> 1.7.1.1
>>>>>
>>>>
>>>
>>> i haven't any preferneces, the only thing is - it would be logical
>>> to have every check in common style, so other cases
>>> (r600_blit_copy, r600_blit_swap) should be fixed, nop?
>>
>> Those are void functions so there's nothing to return.
>
> i mean both of them call r600_nomm_get_vb and both of them
> check if (!dev_priv->blit_vb), not return  value.I mean would be
> logical to check it the same way everytime r600_nomm_get_vb
> gets called.

yeah, either way.  You just need to return an error in r600_prepare_blit_copy.

Alex

>
>> Alex
>>
>>>
>>> --
>>> Best regards.
>>>        Alexander Y. Fomichev <git.user@gmail.com>
>>>
>>
>
>
>
> --
> Best regards.
>        Alexander Y. Fomichev <git.user@gmail.com>
>

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

* Re: drivers/gpu/drm/radeon/r600_blit.c: fix possible NULL pointer  derefernce
  2010-07-20 21:07       ` Alexander Y. Fomichev
  2010-07-20 21:29         ` Alex Deucher
@ 2010-07-21  0:30         ` Dave Airlie
  1 sibling, 0 replies; 8+ messages in thread
From: Dave Airlie @ 2010-07-21  0:30 UTC (permalink / raw)
  To: Alexander Y. Fomichev
  Cc: Alex Deucher, Robert Noland, Matt Turner, Jerome Glisse, akpm,
	dri-devel, linux-kernel

On Wed, 2010-07-21 at 01:07 +0400, Alexander Y. Fomichev wrote:
> On Wed, Jul 21, 2010 at 1:00 AM, Alex Deucher <alexdeucher@gmail.com> wrote:
> > On Tue, Jul 20, 2010 at 4:13 PM, Alexander Y. Fomichev
> > <git.user@gmail.com> wrote:
> >> On Tue, Jul 20, 2010 at 9:37 PM, Alex Deucher <alexdeucher@gmail.com> wrote:
> >>> On Mon, Jul 19, 2010 at 5:42 PM, Alexander Y. Fomichev
> >>> <git.user@gmail.com> wrote:
> >>>> This patch fix possible NULL pointer dereference when
> >>>> r600_prepare_blit_copy tries to fill dev_priv->blit_vb->file_priv
> >>>> without check of dev_priv->blit_vb. dev_priv->blit_vb should be
> >>>> filled by r600_nomm_get_vb but latest can fail with EAGAIN.
> >>>> Addresses: https://bugzilla.kernel.org/show_bug.cgi?id=16375
> >>>>
> >>>> ---
> >>>>  drivers/gpu/drm/radeon/r600_blit.c |    2 ++
> >>>>  1 files changed, 2 insertions(+), 0 deletions(-)
> >>>>
> >>>> diff --git a/drivers/gpu/drm/radeon/r600_blit.c b/drivers/gpu/drm/radeon/r600_blit.c
> >>>> index f4fb88e..0df4a2b 100644
> >>>> --- a/drivers/gpu/drm/radeon/r600_blit.c
> >>>> +++ b/drivers/gpu/drm/radeon/r600_blit.c
> >>>> @@ -541,6 +541,8 @@ r600_prepare_blit_copy(struct drm_device *dev, struct drm_file *file_priv)
> >>>>        DRM_DEBUG("\n");
> >>>>
> >>>>        r600_nomm_get_vb(dev);
> >>>> +       if (!dev_priv->blit_vb)
> >>>> +               return;
> >>>
> >>> r600_prepare_blit_copy returns an int so something like this would be better:
> >>> --- a/drivers/gpu/drm/radeon/r600_blit.c
> >>> +++ b/drivers/gpu/drm/radeon/r600_blit.c
> >>> @@ -539,8 +539,10 @@ r600_prepare_blit_copy(struct drm_device *dev,
> >>> struct drm_file *file_priv)
> >>>  {
> >>>        drm_radeon_private_t *dev_priv = dev->dev_private;
> >>>        DRM_DEBUG("\n");
> >>> +       int ret = r600_nomm_get_vb(dev);
> >>>
> >>> -       r600_nomm_get_vb(dev);
> >>> +       if (ret)
> >>> +               return ret;
> >>>
> >>>        dev_priv->blit_vb->file_priv = file_priv;
> >>>
> >>>
> >>> Alex
> >>>
> >>>>
> >>>>        dev_priv->blit_vb->file_priv = file_priv;
> >>>>
> >>>> --
> >>>> 1.7.1.1
> >>>>
> >>>
> >>
> >> i haven't any preferneces, the only thing is - it would be logical
> >> to have every check in common style, so other cases
> >> (r600_blit_copy, r600_blit_swap) should be fixed, nop?
> >
> > Those are void functions so there's nothing to return.
> 
> i mean both of them call r600_nomm_get_vb and both of them
> check if (!dev_priv->blit_vb), not return  value.I mean would be
> logical to check it the same way everytime r600_nomm_get_vb
> gets called.

I'm going to go with Alex's patch, as none of the other callsites return
an error, and your patch doesn't return value from a function which has
a int return type, causing a warning.

Dave.




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

* Re: drivers/gpu/drm/radeon/r600_blit.c: fix possible NULL pointer  derefernce
  2010-07-20 21:29         ` Alex Deucher
@ 2010-07-21  7:06           ` Alexander Y. Fomichev
  0 siblings, 0 replies; 8+ messages in thread
From: Alexander Y. Fomichev @ 2010-07-21  7:06 UTC (permalink / raw)
  To: Alex Deucher
  Cc: Dave Airlie, Robert Noland, Matt Turner, Jerome Glisse, akpm,
	dri-devel, linux-kernel

On Wed, Jul 21, 2010 at 1:29 AM, Alex Deucher <alexdeucher@gmail.com> wrote:
> On Tue, Jul 20, 2010 at 5:07 PM, Alexander Y. Fomichev
> <git.user@gmail.com> wrote:
>> On Wed, Jul 21, 2010 at 1:00 AM, Alex Deucher <alexdeucher@gmail.com> wrote:
>>> On Tue, Jul 20, 2010 at 4:13 PM, Alexander Y. Fomichev
>>> <git.user@gmail.com> wrote:
>>>> On Tue, Jul 20, 2010 at 9:37 PM, Alex Deucher <alexdeucher@gmail.com> wrote:
>>>>> On Mon, Jul 19, 2010 at 5:42 PM, Alexander Y. Fomichev
>>>>> <git.user@gmail.com> wrote:
>>>>>> This patch fix possible NULL pointer dereference when
>>>>>> r600_prepare_blit_copy tries to fill dev_priv->blit_vb->file_priv
>>>>>> without check of dev_priv->blit_vb. dev_priv->blit_vb should be
>>>>>> filled by r600_nomm_get_vb but latest can fail with EAGAIN.
>>>>>> Addresses: https://bugzilla.kernel.org/show_bug.cgi?id=16375
>>>>>>
>>>>>> ---
>>>>>>  drivers/gpu/drm/radeon/r600_blit.c |    2 ++
>>>>>>  1 files changed, 2 insertions(+), 0 deletions(-)
>>>>>>
>>>>>> diff --git a/drivers/gpu/drm/radeon/r600_blit.c b/drivers/gpu/drm/radeon/r600_blit.c
>>>>>> index f4fb88e..0df4a2b 100644
>>>>>> --- a/drivers/gpu/drm/radeon/r600_blit.c
>>>>>> +++ b/drivers/gpu/drm/radeon/r600_blit.c
>>>>>> @@ -541,6 +541,8 @@ r600_prepare_blit_copy(struct drm_device *dev, struct drm_file *file_priv)
>>>>>>        DRM_DEBUG("\n");
>>>>>>
>>>>>>        r600_nomm_get_vb(dev);
>>>>>> +       if (!dev_priv->blit_vb)
>>>>>> +               return;
>>>>>
>>>>> r600_prepare_blit_copy returns an int so something like this would be better:
>>>>> --- a/drivers/gpu/drm/radeon/r600_blit.c
>>>>> +++ b/drivers/gpu/drm/radeon/r600_blit.c
>>>>> @@ -539,8 +539,10 @@ r600_prepare_blit_copy(struct drm_device *dev,
>>>>> struct drm_file *file_priv)
>>>>>  {
>>>>>        drm_radeon_private_t *dev_priv = dev->dev_private;
>>>>>        DRM_DEBUG("\n");
>>>>> +       int ret = r600_nomm_get_vb(dev);
>>>>>
>>>>> -       r600_nomm_get_vb(dev);
>>>>> +       if (ret)
>>>>> +               return ret;
>>>>>
>>>>>        dev_priv->blit_vb->file_priv = file_priv;
>>>>>
>>>>>
>>>>> Alex
>>>>>
>>>>>>
>>>>>>        dev_priv->blit_vb->file_priv = file_priv;
>>>>>>
>>>>>> --
>>>>>> 1.7.1.1
>>>>>>
>>>>>
>>>>
>>>> i haven't any preferneces, the only thing is - it would be logical
>>>> to have every check in common style, so other cases
>>>> (r600_blit_copy, r600_blit_swap) should be fixed, nop?
>>>
>>> Those are void functions so there's nothing to return.
>>
>> i mean both of them call r600_nomm_get_vb and both of them
>> check if (!dev_priv->blit_vb), not return  value.I mean would be
>> logical to check it the same way everytime r600_nomm_get_vb
>> gets called.
>
> yeah, either way.  You just need to return an error in r600_prepare_blit_copy.
uh-huh, i've missed

> Alex
>
>>
>>> Alex
>>>
>>>>
>>>> --
>>>> Best regards.
>>>>        Alexander Y. Fomichev <git.user@gmail.com>
>>>>
>>>
>>
>>
>>
>> --
>> Best regards.
>>        Alexander Y. Fomichev <git.user@gmail.com>
>>
>


-- 
Best regards.
       Alexander Y. Fomichev <git.user@gmail.com>

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

end of thread, other threads:[~2010-07-21  7:06 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-07-19 21:42 drivers/gpu/drm/radeon/r600_blit.c: fix possible NULL pointer derefernce Alexander Y. Fomichev
2010-07-20 17:37 ` Alex Deucher
2010-07-20 20:13   ` Alexander Y. Fomichev
2010-07-20 21:00     ` Alex Deucher
2010-07-20 21:07       ` Alexander Y. Fomichev
2010-07-20 21:29         ` Alex Deucher
2010-07-21  7:06           ` Alexander Y. Fomichev
2010-07-21  0:30         ` Dave Airlie

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