Skip to content

Commit

Permalink
drm/loongson: Add a check for lsdc_bo_create() errors
Browse files Browse the repository at this point in the history
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: f39db26 ("drm: Add kms driver for loongson display controller")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: Sui Jingfeng <suijingfeng@loongson.cn>
Signed-off-by: Sui Jingfeng <sui.jingfeng@linux.dev>
Link: https://patchwork.freedesktop.org/patch/msgid/ZLeijglIMPve2Iio@kadam
  • Loading branch information
Dan Carpenter authored and Sui Jingfeng committed Aug 4, 2023
1 parent e4774e9 commit b0e9267
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions drivers/gpu/drm/loongson/lsdc_ttm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down

0 comments on commit b0e9267

Please sign in to comment.