* [PATCH v2] drm/loongson: Add a check for lsdc_bo_create() errors
@ 2023-07-19 8:45 ` Dan Carpenter
0 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2023-07-19 8:45 UTC (permalink / raw)
To: Sui Jingfeng
Cc: David Airlie, Daniel Vetter, Thomas Zimmermann, dri-devel,
kernel-janitors
This code doesn't check for lsdc_bo_create() failure and it could lead
to a crash. It can fail for a variety of reasons, but the most common
cause would be low memory. Add a check.
Fixes: f39db26c5428 ("drm: Add kms driver for loongson display controller")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: Sui Jingfeng <suijingfeng@loongson.cn>
---
v2: change subject and re-word the commit message
drivers/gpu/drm/loongson/lsdc_ttm.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/gpu/drm/loongson/lsdc_ttm.c b/drivers/gpu/drm/loongson/lsdc_ttm.c
index bb0c8fd43a75..bf79dc55afa4 100644
--- a/drivers/gpu/drm/loongson/lsdc_ttm.c
+++ b/drivers/gpu/drm/loongson/lsdc_ttm.c
@@ -496,6 +496,8 @@ struct lsdc_bo *lsdc_bo_create_kernel_pinned(struct drm_device *ddev,
int ret;
lbo = lsdc_bo_create(ddev, domain, size, true, NULL, NULL);
+ if (IS_ERR(lbo))
+ return ERR_CAST(lbo);
ret = lsdc_bo_reserve(lbo);
if (unlikely(ret)) {
--
2.39.2
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH v2] drm/loongson: Add a check for lsdc_bo_create() errors
@ 2023-07-19 8:45 ` Dan Carpenter
0 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2023-07-19 8:45 UTC (permalink / raw)
To: Sui Jingfeng; +Cc: kernel-janitors, dri-devel, Thomas Zimmermann
This code doesn't check for lsdc_bo_create() failure and it could lead
to a crash. It can fail for a variety of reasons, but the most common
cause would be low memory. Add a check.
Fixes: f39db26c5428 ("drm: Add kms driver for loongson display controller")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: Sui Jingfeng <suijingfeng@loongson.cn>
---
v2: change subject and re-word the commit message
drivers/gpu/drm/loongson/lsdc_ttm.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/gpu/drm/loongson/lsdc_ttm.c b/drivers/gpu/drm/loongson/lsdc_ttm.c
index bb0c8fd43a75..bf79dc55afa4 100644
--- a/drivers/gpu/drm/loongson/lsdc_ttm.c
+++ b/drivers/gpu/drm/loongson/lsdc_ttm.c
@@ -496,6 +496,8 @@ struct lsdc_bo *lsdc_bo_create_kernel_pinned(struct drm_device *ddev,
int ret;
lbo = lsdc_bo_create(ddev, domain, size, true, NULL, NULL);
+ if (IS_ERR(lbo))
+ return ERR_CAST(lbo);
ret = lsdc_bo_reserve(lbo);
if (unlikely(ret)) {
--
2.39.2
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH v2] drm/loongson: Add a check for lsdc_bo_create() errors
2023-07-19 8:45 ` Dan Carpenter
@ 2023-07-19 10:40 ` suijingfeng
-1 siblings, 0 replies; 4+ messages in thread
From: suijingfeng @ 2023-07-19 10:40 UTC (permalink / raw)
To: Dan Carpenter
Cc: David Airlie, Daniel Vetter, Thomas Zimmermann, dri-devel,
kernel-janitors
Hi,
This version is ok, I'll apply this patch within a few days.
On 2023/7/19 16:45, Dan Carpenter wrote:
> This code doesn't check for lsdc_bo_create() failure and it could lead
> to a crash. It can fail for a variety of reasons, but the most common
> cause would be low memory. Add a check.
>
> Fixes: f39db26c5428 ("drm: Add kms driver for loongson display controller")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> Reviewed-by: Sui Jingfeng <suijingfeng@loongson.cn>
> ---
> v2: change subject and re-word the commit message
>
> drivers/gpu/drm/loongson/lsdc_ttm.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/gpu/drm/loongson/lsdc_ttm.c b/drivers/gpu/drm/loongson/lsdc_ttm.c
> index bb0c8fd43a75..bf79dc55afa4 100644
> --- a/drivers/gpu/drm/loongson/lsdc_ttm.c
> +++ b/drivers/gpu/drm/loongson/lsdc_ttm.c
> @@ -496,6 +496,8 @@ struct lsdc_bo *lsdc_bo_create_kernel_pinned(struct drm_device *ddev,
> int ret;
>
> lbo = lsdc_bo_create(ddev, domain, size, true, NULL, NULL);
> + if (IS_ERR(lbo))
> + return ERR_CAST(lbo);
>
> ret = lsdc_bo_reserve(lbo);
> if (unlikely(ret)) {
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH v2] drm/loongson: Add a check for lsdc_bo_create() errors
@ 2023-07-19 10:40 ` suijingfeng
0 siblings, 0 replies; 4+ messages in thread
From: suijingfeng @ 2023-07-19 10:40 UTC (permalink / raw)
To: Dan Carpenter; +Cc: kernel-janitors, dri-devel, Thomas Zimmermann
Hi,
This version is ok, I'll apply this patch within a few days.
On 2023/7/19 16:45, Dan Carpenter wrote:
> This code doesn't check for lsdc_bo_create() failure and it could lead
> to a crash. It can fail for a variety of reasons, but the most common
> cause would be low memory. Add a check.
>
> Fixes: f39db26c5428 ("drm: Add kms driver for loongson display controller")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> Reviewed-by: Sui Jingfeng <suijingfeng@loongson.cn>
> ---
> v2: change subject and re-word the commit message
>
> drivers/gpu/drm/loongson/lsdc_ttm.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/gpu/drm/loongson/lsdc_ttm.c b/drivers/gpu/drm/loongson/lsdc_ttm.c
> index bb0c8fd43a75..bf79dc55afa4 100644
> --- a/drivers/gpu/drm/loongson/lsdc_ttm.c
> +++ b/drivers/gpu/drm/loongson/lsdc_ttm.c
> @@ -496,6 +496,8 @@ struct lsdc_bo *lsdc_bo_create_kernel_pinned(struct drm_device *ddev,
> int ret;
>
> lbo = lsdc_bo_create(ddev, domain, size, true, NULL, NULL);
> + if (IS_ERR(lbo))
> + return ERR_CAST(lbo);
>
> ret = lsdc_bo_reserve(lbo);
> if (unlikely(ret)) {
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-07-19 10:41 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-19 8:45 [PATCH v2] drm/loongson: Add a check for lsdc_bo_create() errors Dan Carpenter
2023-07-19 8:45 ` Dan Carpenter
2023-07-19 10:40 ` suijingfeng
2023-07-19 10:40 ` suijingfeng
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.