* [PATCH] drm/exynos: fix pages allocation in lowlevel_buffer_allocate
@ 2013-07-02 10:59 Seung-Woo Kim
2013-07-02 11:36 ` Ville Syrjälä
0 siblings, 1 reply; 8+ messages in thread
From: Seung-Woo Kim @ 2013-07-02 10:59 UTC (permalink / raw)
To: dri-devel, inki.dae; +Cc: kyungmin.park, sw0312.kim, yj44.cho
From: YoungJun Cho <yj44.cho@samsung.com>
When drm iommu is not supported, buf->pages has to be allocated
and assigned to phys_to_page() result, which type is struct page *.
So it is sufficient to allocate buf->pages with multiple struct
page pointer size.
Signed-off-by: YoungJun Cho <yj44.cho@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
---
drivers/gpu/drm/exynos/exynos_drm_buf.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/exynos/exynos_drm_buf.c b/drivers/gpu/drm/exynos/exynos_drm_buf.c
index 22865ba..3200622 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_buf.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_buf.c
@@ -57,7 +57,7 @@ static int lowlevel_buffer_allocate(struct drm_device *dev,
dma_addr_t start_addr;
unsigned int i = 0;
- buf->pages = kzalloc(sizeof(struct page) * nr_pages,
+ buf->pages = kzalloc(sizeof(struct page *) * nr_pages,
GFP_KERNEL);
if (!buf->pages) {
DRM_ERROR("failed to allocate pages.\n");
--
1.7.9.5
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] drm/exynos: fix pages allocation in lowlevel_buffer_allocate
2013-07-02 10:59 [PATCH] drm/exynos: fix pages allocation in lowlevel_buffer_allocate Seung-Woo Kim
@ 2013-07-02 11:36 ` Ville Syrjälä
2013-07-02 12:23 ` YoungJun Cho
0 siblings, 1 reply; 8+ messages in thread
From: Ville Syrjälä @ 2013-07-02 11:36 UTC (permalink / raw)
To: Seung-Woo Kim; +Cc: kyungmin.park, yj44.cho, dri-devel
On Tue, Jul 02, 2013 at 07:59:22PM +0900, Seung-Woo Kim wrote:
> From: YoungJun Cho <yj44.cho@samsung.com>
>
> When drm iommu is not supported, buf->pages has to be allocated
> and assigned to phys_to_page() result, which type is struct page *.
> So it is sufficient to allocate buf->pages with multiple struct
> page pointer size.
>
> Signed-off-by: YoungJun Cho <yj44.cho@samsung.com>
> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
> ---
> drivers/gpu/drm/exynos/exynos_drm_buf.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/exynos/exynos_drm_buf.c b/drivers/gpu/drm/exynos/exynos_drm_buf.c
> index 22865ba..3200622 100644
> --- a/drivers/gpu/drm/exynos/exynos_drm_buf.c
> +++ b/drivers/gpu/drm/exynos/exynos_drm_buf.c
> @@ -57,7 +57,7 @@ static int lowlevel_buffer_allocate(struct drm_device *dev,
> dma_addr_t start_addr;
> unsigned int i = 0;
>
> - buf->pages = kzalloc(sizeof(struct page) * nr_pages,
> + buf->pages = kzalloc(sizeof(struct page *) * nr_pages,
> GFP_KERNEL);
Looks like a prime candidate for kcalloc()
> if (!buf->pages) {
> DRM_ERROR("failed to allocate pages.\n");
> --
> 1.7.9.5
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel
--
Ville Syrjälä
Intel OTC
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] drm/exynos: fix pages allocation in lowlevel_buffer_allocate
2013-07-02 11:36 ` Ville Syrjälä
@ 2013-07-02 12:23 ` YoungJun Cho
2013-07-02 12:41 ` Inki Dae
0 siblings, 1 reply; 8+ messages in thread
From: YoungJun Cho @ 2013-07-02 12:23 UTC (permalink / raw)
To: Ville Syrjälä; +Cc: kyungmin.park, Seung-Woo Kim, dri-devel
[-- Attachment #1.1: Type: text/plain, Size: 1992 bytes --]
Dear Ville
On Jul 2, 2013 8:42 PM, "Ville Syrjälä" <ville.syrjala@linux.intel.com>
wrote:
>
> On Tue, Jul 02, 2013 at 07:59:22PM +0900, Seung-Woo Kim wrote:
> > From: YoungJun Cho <yj44.cho@samsung.com>
> >
> > When drm iommu is not supported, buf->pages has to be allocated
> > and assigned to phys_to_page() result, which type is struct page *.
> > So it is sufficient to allocate buf->pages with multiple struct
> > page pointer size.
> >
> > Signed-off-by: YoungJun Cho <yj44.cho@samsung.com>
> > Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
> > ---
> > drivers/gpu/drm/exynos/exynos_drm_buf.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/gpu/drm/exynos/exynos_drm_buf.c
b/drivers/gpu/drm/exynos/exynos_drm_buf.c
> > index 22865ba..3200622 100644
> > --- a/drivers/gpu/drm/exynos/exynos_drm_buf.c
> > +++ b/drivers/gpu/drm/exynos/exynos_drm_buf.c
> > @@ -57,7 +57,7 @@ static int lowlevel_buffer_allocate(struct drm_device
*dev,
> > dma_addr_t start_addr;
> > unsigned int i = 0;
> >
> > - buf->pages = kzalloc(sizeof(struct page) * nr_pages,
> > + buf->pages = kzalloc(sizeof(struct page *) * nr_pages,
> > GFP_KERNEL);
>
> Looks like a prime candidate for kcalloc()
>
Thank you for nice comments.
I had no idea to consider overflow!
I'll update again.
Best regards YJ
> > if (!buf->pages) {
> > DRM_ERROR("failed to allocate pages.\n");
> > --
> > 1.7.9.5
> >
> > _______________________________________________
> > dri-devel mailing list
> > dri-devel@lists.freedesktop.org
> > http://lists.freedesktop.org/mailman/listinfo/dri-devel
>
> --
> Ville Syrjälä
> Intel OTC
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel
[-- Attachment #1.2: Type: text/html, Size: 2999 bytes --]
[-- Attachment #2: Type: text/plain, Size: 159 bytes --]
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] drm/exynos: fix pages allocation in lowlevel_buffer_allocate
2013-07-02 12:23 ` YoungJun Cho
@ 2013-07-02 12:41 ` Inki Dae
2013-07-03 0:07 ` YoungJun Cho
2013-07-03 8:09 ` [PATCH 1/3] drm/exynos: use drm_calloc_large when allocates pointer array Seung-Woo Kim
0 siblings, 2 replies; 8+ messages in thread
From: Inki Dae @ 2013-07-02 12:41 UTC (permalink / raw)
To: YoungJun Cho; +Cc: Kyungmin Park, Seung-Woo Kim, DRI mailing list
2013/7/2 YoungJun Cho <yj44.cho@samsung.com>:
> Dear Ville
>
> On Jul 2, 2013 8:42 PM, "Ville Syrjälä" <ville.syrjala@linux.intel.com>
> wrote:
>>
>> On Tue, Jul 02, 2013 at 07:59:22PM +0900, Seung-Woo Kim wrote:
>> > From: YoungJun Cho <yj44.cho@samsung.com>
>> >
>> > When drm iommu is not supported, buf->pages has to be allocated
>> > and assigned to phys_to_page() result, which type is struct page *.
>> > So it is sufficient to allocate buf->pages with multiple struct
>> > page pointer size.
>> >
>> > Signed-off-by: YoungJun Cho <yj44.cho@samsung.com>
>> > Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
>> > ---
>> > drivers/gpu/drm/exynos/exynos_drm_buf.c | 2 +-
>> > 1 file changed, 1 insertion(+), 1 deletion(-)
>> >
>> > diff --git a/drivers/gpu/drm/exynos/exynos_drm_buf.c
>> > b/drivers/gpu/drm/exynos/exynos_drm_buf.c
>> > index 22865ba..3200622 100644
>> > --- a/drivers/gpu/drm/exynos/exynos_drm_buf.c
>> > +++ b/drivers/gpu/drm/exynos/exynos_drm_buf.c
>> > @@ -57,7 +57,7 @@ static int lowlevel_buffer_allocate(struct drm_device
>> > *dev,
>> > dma_addr_t start_addr;
>> > unsigned int i = 0;
>> >
>> > - buf->pages = kzalloc(sizeof(struct page) * nr_pages,
>> > + buf->pages = kzalloc(sizeof(struct page *) * nr_pages,
>> > GFP_KERNEL);
>>
>> Looks like a prime candidate for kcalloc()
>>
>
> Thank you for nice comments.
> I had no idea to consider overflow!
>
> I'll update again.
Mr. Cho,
it seems better to use utility function, drm_calloc_large().
Thanks,
Inki Dae
>
> Best regards YJ
>
>> > if (!buf->pages) {
>> > DRM_ERROR("failed to allocate pages.\n");
>> > --
>> > 1.7.9.5
>> >
>> > _______________________________________________
>> > dri-devel mailing list
>> > dri-devel@lists.freedesktop.org
>> > http://lists.freedesktop.org/mailman/listinfo/dri-devel
>>
>> --
>> Ville Syrjälä
>> Intel OTC
>> _______________________________________________
>> dri-devel mailing list
>> dri-devel@lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/dri-devel
>
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] drm/exynos: fix pages allocation in lowlevel_buffer_allocate
2013-07-02 12:41 ` Inki Dae
@ 2013-07-03 0:07 ` YoungJun Cho
2013-07-03 8:09 ` [PATCH 1/3] drm/exynos: use drm_calloc_large when allocates pointer array Seung-Woo Kim
1 sibling, 0 replies; 8+ messages in thread
From: YoungJun Cho @ 2013-07-03 0:07 UTC (permalink / raw)
To: Inki Dae; +Cc: Kyungmin Park, sw0312.kim, dri-devel
[-- Attachment #1.1: Type: text/plain, Size: 2895 bytes --]
Dear Mr.Dae,
On Jul 2, 2013 9:42 PM, "Inki Dae" <inki.dae@samsung.com> wrote:
>
> 2013/7/2 YoungJun Cho <yj44.cho@samsung.com>:
> > Dear Ville
> >
> > On Jul 2, 2013 8:42 PM, "Ville Syrjälä" <ville.syrjala@linux.intel.com>
> > wrote:
> >>
> >> On Tue, Jul 02, 2013 at 07:59:22PM +0900, Seung-Woo Kim wrote:
> >> > From: YoungJun Cho <yj44.cho@samsung.com>
> >> >
> >> > When drm iommu is not supported, buf->pages has to be allocated
> >> > and assigned to phys_to_page() result, which type is struct page *.
> >> > So it is sufficient to allocate buf->pages with multiple struct
> >> > page pointer size.
> >> >
> >> > Signed-off-by: YoungJun Cho <yj44.cho@samsung.com>
> >> > Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
> >> > ---
> >> > drivers/gpu/drm/exynos/exynos_drm_buf.c | 2 +-
> >> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >> >
> >> > diff --git a/drivers/gpu/drm/exynos/exynos_drm_buf.c
> >> > b/drivers/gpu/drm/exynos/exynos_drm_buf.c
> >> > index 22865ba..3200622 100644
> >> > --- a/drivers/gpu/drm/exynos/exynos_drm_buf.c
> >> > +++ b/drivers/gpu/drm/exynos/exynos_drm_buf.c
> >> > @@ -57,7 +57,7 @@ static int lowlevel_buffer_allocate(struct
drm_device
> >> > *dev,
> >> > dma_addr_t start_addr;
> >> > unsigned int i = 0;
> >> >
> >> > - buf->pages = kzalloc(sizeof(struct page) * nr_pages,
> >> > + buf->pages = kzalloc(sizeof(struct page *) * nr_pages,
> >> > GFP_KERNEL);
> >>
> >> Looks like a prime candidate for kcalloc()
> >>
> >
> > Thank you for nice comments.
> > I had no idea to consider overflow!
> >
> > I'll update again.
>
> Mr. Cho,
>
> it seems better to use utility function, drm_calloc_large().
>
Your comment is more suitable for this patch. I'll use it.
Thank you!
Best regards YJ
> Thanks,
> Inki Dae
>
> >
> > Best regards YJ
> >
> >> > if (!buf->pages) {
> >> > DRM_ERROR("failed to allocate pages.\n");
> >> > --
> >> > 1.7.9.5
> >> >
> >> > _______________________________________________
> >> > dri-devel mailing list
> >> > dri-devel@lists.freedesktop.org
> >> > http://lists.freedesktop.org/mailman/listinfo/dri-devel
> >>
> >> --
> >> Ville Syrjälä
> >> Intel OTC
> >> _______________________________________________
> >> dri-devel mailing list
> >> dri-devel@lists.freedesktop.org
> >> http://lists.freedesktop.org/mailman/listinfo/dri-devel
> >
> >
> > _______________________________________________
> > dri-devel mailing list
> > dri-devel@lists.freedesktop.org
> > http://lists.freedesktop.org/mailman/listinfo/dri-devel
> >
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel
[-- Attachment #1.2: Type: text/html, Size: 4852 bytes --]
[-- Attachment #2: Type: text/plain, Size: 159 bytes --]
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 1/3] drm/exynos: use drm_calloc_large when allocates pointer array
2013-07-02 12:41 ` Inki Dae
2013-07-03 0:07 ` YoungJun Cho
@ 2013-07-03 8:09 ` Seung-Woo Kim
2013-07-03 8:09 ` [PATCH v2 2/3] drm/exynos: fix pages allocation size in lowlevel_buffer_allocate Seung-Woo Kim
2013-07-03 8:09 ` [PATCH 3/3] drm/exynos: remove duplicated error routine and unnecessary assign Seung-Woo Kim
1 sibling, 2 replies; 8+ messages in thread
From: Seung-Woo Kim @ 2013-07-03 8:09 UTC (permalink / raw)
To: dri-devel, inki.dae; +Cc: sw0312.kim, yj44.cho, kyungmin.park
From: YoungJun Cho <yj44.cho@samsung.com>
If the type of object is pointer array, the drm_calloc_large() is
more suitable than kzalloc() for its allocation function. And uses
drm_free_large() instead of kfree() also.
Signed-off-by: YoungJun Cho <yj44.cho@samsung.com>
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
---
drivers/gpu/drm/exynos/exynos_drm_buf.c | 9 ++++-----
drivers/gpu/drm/exynos/exynos_drm_g2d.c | 6 +++---
2 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/drivers/gpu/drm/exynos/exynos_drm_buf.c b/drivers/gpu/drm/exynos/exynos_drm_buf.c
index 22865ba..245c9ae 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_buf.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_buf.c
@@ -57,8 +57,7 @@ static int lowlevel_buffer_allocate(struct drm_device *dev,
dma_addr_t start_addr;
unsigned int i = 0;
- buf->pages = kzalloc(sizeof(struct page) * nr_pages,
- GFP_KERNEL);
+ buf->pages = drm_calloc_large(nr_pages, sizeof(struct page));
if (!buf->pages) {
DRM_ERROR("failed to allocate pages.\n");
return -ENOMEM;
@@ -69,7 +68,7 @@ static int lowlevel_buffer_allocate(struct drm_device *dev,
&buf->dma_attrs);
if (!buf->kvaddr) {
DRM_ERROR("failed to allocate buffer.\n");
- kfree(buf->pages);
+ drm_free_large(buf->pages);
return -ENOMEM;
}
@@ -109,7 +108,7 @@ err_free_attrs:
buf->dma_addr = (dma_addr_t)NULL;
if (!is_drm_iommu_supported(dev))
- kfree(buf->pages);
+ drm_free_large(buf->pages);
return ret;
}
@@ -134,7 +133,7 @@ static void lowlevel_buffer_deallocate(struct drm_device *dev,
if (!is_drm_iommu_supported(dev)) {
dma_free_attrs(dev->dev, buf->size, buf->kvaddr,
(dma_addr_t)buf->dma_addr, &buf->dma_attrs);
- kfree(buf->pages);
+ drm_free_large(buf->pages);
} else
dma_free_attrs(dev->dev, buf->size, buf->pages,
(dma_addr_t)buf->dma_addr, &buf->dma_attrs);
diff --git a/drivers/gpu/drm/exynos/exynos_drm_g2d.c b/drivers/gpu/drm/exynos/exynos_drm_g2d.c
index af75434..fb19ee5 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_g2d.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_g2d.c
@@ -390,7 +390,7 @@ out:
kfree(g2d_userptr->sgt);
g2d_userptr->sgt = NULL;
- kfree(g2d_userptr->pages);
+ drm_free_large(g2d_userptr->pages);
g2d_userptr->pages = NULL;
kfree(g2d_userptr);
g2d_userptr = NULL;
@@ -463,7 +463,7 @@ static dma_addr_t *g2d_userptr_get_dma_addr(struct drm_device *drm_dev,
npages = (end - start) >> PAGE_SHIFT;
g2d_userptr->npages = npages;
- pages = kzalloc(npages * sizeof(struct page *), GFP_KERNEL);
+ pages = drm_calloc_large(npages, sizeof(struct page *));
if (!pages) {
DRM_ERROR("failed to allocate pages.\n");
kfree(g2d_userptr);
@@ -554,7 +554,7 @@ err_put_vma:
exynos_gem_put_vma(g2d_userptr->vma);
err_free_pages:
- kfree(pages);
+ drm_free_large(pages);
kfree(g2d_userptr);
pages = NULL;
g2d_userptr = NULL;
--
1.7.4.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v2 2/3] drm/exynos: fix pages allocation size in lowlevel_buffer_allocate
2013-07-03 8:09 ` [PATCH 1/3] drm/exynos: use drm_calloc_large when allocates pointer array Seung-Woo Kim
@ 2013-07-03 8:09 ` Seung-Woo Kim
2013-07-03 8:09 ` [PATCH 3/3] drm/exynos: remove duplicated error routine and unnecessary assign Seung-Woo Kim
1 sibling, 0 replies; 8+ messages in thread
From: Seung-Woo Kim @ 2013-07-03 8:09 UTC (permalink / raw)
To: dri-devel, inki.dae; +Cc: sw0312.kim, yj44.cho, kyungmin.park
From: YoungJun Cho <yj44.cho@samsung.com>
When IOMMU is not supported, buf->pages has to be allocated to
assign the result of phys_to_page() which return type is struct
page *. So it is sufficient to allocate buf->pages with the size
of multiple struct page pointers.
Signed-off-by: YoungJun Cho <yj44.cho@samsung.com>
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
---
change from v1:
- adds precedence patch to fix allocation of array as Ville and Inki commented
drivers/gpu/drm/exynos/exynos_drm_buf.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/drivers/gpu/drm/exynos/exynos_drm_buf.c b/drivers/gpu/drm/exynos/exynos_drm_buf.c
index 245c9ae..c300b2a 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_buf.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_buf.c
@@ -57,7 +57,7 @@ static int lowlevel_buffer_allocate(struct drm_device *dev,
dma_addr_t start_addr;
unsigned int i = 0;
- buf->pages = drm_calloc_large(nr_pages, sizeof(struct page));
+ buf->pages = drm_calloc_large(nr_pages, sizeof(struct page *));
if (!buf->pages) {
DRM_ERROR("failed to allocate pages.\n");
return -ENOMEM;
--
1.7.4.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 3/3] drm/exynos: remove duplicated error routine and unnecessary assign
2013-07-03 8:09 ` [PATCH 1/3] drm/exynos: use drm_calloc_large when allocates pointer array Seung-Woo Kim
2013-07-03 8:09 ` [PATCH v2 2/3] drm/exynos: fix pages allocation size in lowlevel_buffer_allocate Seung-Woo Kim
@ 2013-07-03 8:09 ` Seung-Woo Kim
1 sibling, 0 replies; 8+ messages in thread
From: Seung-Woo Kim @ 2013-07-03 8:09 UTC (permalink / raw)
To: dri-devel, inki.dae; +Cc: sw0312.kim, yj44.cho, kyungmin.park
There were duplicated error handling routines during allocating
pages in lowlevel_buffer_allocate() and g2d_userptr_get_dma_addr().
Also unnecessary NULL assignments for variable used not any more
are removed from g2d_userptr_get_dma_addr() and
g2d_userptr_put_dma_addr().
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Signed-off-by: YoungJun Cho <yj44.cho@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
---
drivers/gpu/drm/exynos/exynos_drm_buf.c | 6 +++---
drivers/gpu/drm/exynos/exynos_drm_g2d.c | 12 ++++--------
2 files changed, 7 insertions(+), 11 deletions(-)
diff --git a/drivers/gpu/drm/exynos/exynos_drm_buf.c b/drivers/gpu/drm/exynos/exynos_drm_buf.c
index 518b6d8..b8ac06d 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_buf.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_buf.c
@@ -68,8 +68,8 @@ static int lowlevel_buffer_allocate(struct drm_device *dev,
&buf->dma_attrs);
if (!buf->kvaddr) {
DRM_ERROR("failed to allocate buffer.\n");
- drm_free_large(buf->pages);
- return -ENOMEM;
+ ret = -ENOMEM;
+ goto err_free;
}
start_addr = buf->dma_addr;
@@ -106,7 +106,7 @@ err_free_attrs:
dma_free_attrs(dev->dev, buf->size, buf->pages,
(dma_addr_t)buf->dma_addr, &buf->dma_attrs);
buf->dma_addr = (dma_addr_t)NULL;
-
+err_free:
if (!is_drm_iommu_supported(dev))
drm_free_large(buf->pages);
diff --git a/drivers/gpu/drm/exynos/exynos_drm_g2d.c b/drivers/gpu/drm/exynos/exynos_drm_g2d.c
index fb19ee5..42a5a54 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_g2d.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_g2d.c
@@ -388,12 +388,9 @@ out:
sg_free_table(g2d_userptr->sgt);
kfree(g2d_userptr->sgt);
- g2d_userptr->sgt = NULL;
drm_free_large(g2d_userptr->pages);
- g2d_userptr->pages = NULL;
kfree(g2d_userptr);
- g2d_userptr = NULL;
}
static dma_addr_t *g2d_userptr_get_dma_addr(struct drm_device *drm_dev,
@@ -466,8 +463,8 @@ static dma_addr_t *g2d_userptr_get_dma_addr(struct drm_device *drm_dev,
pages = drm_calloc_large(npages, sizeof(struct page *));
if (!pages) {
DRM_ERROR("failed to allocate pages.\n");
- kfree(g2d_userptr);
- return ERR_PTR(-ENOMEM);
+ ret = -ENOMEM;
+ goto err_free;
}
vma = find_vma(current->mm, userptr);
@@ -543,7 +540,6 @@ err_sg_free_table:
err_free_sgt:
kfree(sgt);
- sgt = NULL;
err_free_userptr:
exynos_gem_put_pages_to_userptr(g2d_userptr->pages,
@@ -555,9 +551,9 @@ err_put_vma:
err_free_pages:
drm_free_large(pages);
+
+err_free:
kfree(g2d_userptr);
- pages = NULL;
- g2d_userptr = NULL;
return ERR_PTR(ret);
}
--
1.7.4.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
end of thread, other threads:[~2013-07-03 8:09 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-07-02 10:59 [PATCH] drm/exynos: fix pages allocation in lowlevel_buffer_allocate Seung-Woo Kim
2013-07-02 11:36 ` Ville Syrjälä
2013-07-02 12:23 ` YoungJun Cho
2013-07-02 12:41 ` Inki Dae
2013-07-03 0:07 ` YoungJun Cho
2013-07-03 8:09 ` [PATCH 1/3] drm/exynos: use drm_calloc_large when allocates pointer array Seung-Woo Kim
2013-07-03 8:09 ` [PATCH v2 2/3] drm/exynos: fix pages allocation size in lowlevel_buffer_allocate Seung-Woo Kim
2013-07-03 8:09 ` [PATCH 3/3] drm/exynos: remove duplicated error routine and unnecessary assign Seung-Woo Kim
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.