diff options
Diffstat (limited to 'drivers/gpu/nvgpu')
-rw-r--r-- | drivers/gpu/nvgpu/common/linux/vidmem.c | 6 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/common/mm/vidmem.c | 12 |
2 files changed, 11 insertions, 7 deletions
diff --git a/drivers/gpu/nvgpu/common/linux/vidmem.c b/drivers/gpu/nvgpu/common/linux/vidmem.c index 1d9fea71..684262ba 100644 --- a/drivers/gpu/nvgpu/common/linux/vidmem.c +++ b/drivers/gpu/nvgpu/common/linux/vidmem.c | |||
@@ -173,6 +173,8 @@ int nvgpu_vidmem_export_linux(struct gk20a *g, size_t bytes) | |||
173 | if (!gk20a_get(g)) | 173 | if (!gk20a_get(g)) |
174 | return -ENODEV; | 174 | return -ENODEV; |
175 | 175 | ||
176 | vidmem_dbg(g, "Allocating vidmem buf: %zu bytes", bytes); | ||
177 | |||
176 | priv = nvgpu_kzalloc(g, sizeof(*priv)); | 178 | priv = nvgpu_kzalloc(g, sizeof(*priv)); |
177 | if (!priv) { | 179 | if (!priv) { |
178 | err = -ENOMEM; | 180 | err = -ENOMEM; |
@@ -180,8 +182,8 @@ int nvgpu_vidmem_export_linux(struct gk20a *g, size_t bytes) | |||
180 | } | 182 | } |
181 | 183 | ||
182 | buf = nvgpu_vidmem_user_alloc(g, bytes); | 184 | buf = nvgpu_vidmem_user_alloc(g, bytes); |
183 | if (!buf) { | 185 | if (IS_ERR(buf)) { |
184 | err = -ENOMEM; | 186 | err = PTR_ERR(buf); |
185 | goto fail; | 187 | goto fail; |
186 | } | 188 | } |
187 | 189 | ||
diff --git a/drivers/gpu/nvgpu/common/mm/vidmem.c b/drivers/gpu/nvgpu/common/mm/vidmem.c index 4239bd06..e4137090 100644 --- a/drivers/gpu/nvgpu/common/mm/vidmem.c +++ b/drivers/gpu/nvgpu/common/mm/vidmem.c | |||
@@ -503,16 +503,18 @@ struct nvgpu_vidmem_buf *nvgpu_vidmem_user_alloc(struct gk20a *g, size_t bytes) | |||
503 | 503 | ||
504 | err = nvgpu_vidmem_clear_all(g); | 504 | err = nvgpu_vidmem_clear_all(g); |
505 | if (err) | 505 | if (err) |
506 | return NULL; | 506 | return ERR_PTR(-ENOMEM); |
507 | 507 | ||
508 | buf = nvgpu_kzalloc(g, sizeof(*buf)); | 508 | buf = nvgpu_kzalloc(g, sizeof(*buf)); |
509 | if (!buf) | 509 | if (!buf) |
510 | return NULL; | 510 | return ERR_PTR(-ENOMEM); |
511 | 511 | ||
512 | buf->g = g; | 512 | buf->g = g; |
513 | buf->mem = nvgpu_kzalloc(g, sizeof(*buf->mem)); | 513 | buf->mem = nvgpu_kzalloc(g, sizeof(*buf->mem)); |
514 | if (!buf->mem) | 514 | if (!buf->mem) { |
515 | err = -ENOMEM; | ||
515 | goto fail; | 516 | goto fail; |
517 | } | ||
516 | 518 | ||
517 | err = nvgpu_dma_alloc_vid(g, bytes, buf->mem); | 519 | err = nvgpu_dma_alloc_vid(g, bytes, buf->mem); |
518 | if (err) | 520 | if (err) |
@@ -530,7 +532,7 @@ fail: | |||
530 | /* buf will never be NULL here. */ | 532 | /* buf will never be NULL here. */ |
531 | nvgpu_kfree(g, buf->mem); | 533 | nvgpu_kfree(g, buf->mem); |
532 | nvgpu_kfree(g, buf); | 534 | nvgpu_kfree(g, buf); |
533 | return NULL; | 535 | return ERR_PTR(err); |
534 | } | 536 | } |
535 | 537 | ||
536 | void nvgpu_vidmem_buf_free(struct gk20a *g, struct nvgpu_vidmem_buf *buf) | 538 | void nvgpu_vidmem_buf_free(struct gk20a *g, struct nvgpu_vidmem_buf *buf) |
@@ -538,7 +540,7 @@ void nvgpu_vidmem_buf_free(struct gk20a *g, struct nvgpu_vidmem_buf *buf) | |||
538 | /* | 540 | /* |
539 | * In some error paths it's convenient to be able to "free" a NULL buf. | 541 | * In some error paths it's convenient to be able to "free" a NULL buf. |
540 | */ | 542 | */ |
541 | if (!buf) | 543 | if (IS_ERR_OR_NULL(buf)) |
542 | return; | 544 | return; |
543 | 545 | ||
544 | nvgpu_dma_free(g, buf->mem); | 546 | nvgpu_dma_free(g, buf->mem); |