Commit 5976a28b authored by Harshit Mogalapalli's avatar Harshit Mogalapalli Committed by Sui Jingfeng

drm/loongson: Fix error handling in lsdc_pixel_pll_setup()

There are two problems in lsdc_pixel_pll_setup()
1. If kzalloc() fails then call iounmap() to release the resources.
2. Both kzalloc and ioremap does not return error pointers on failure, so
   using IS_ERR_OR_NULL() checks is a bit confusing and not very right,
   fix this by changing those to NULL checks instead.

Fixes: f39db26c ("drm: Add kms driver for loongson display controller")
Signed-off-by: default avatarHarshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
Reviewed-by: default avatarSui Jingfeng <suijingfeng@loongson.cn>
Signed-off-by: default avatarSui Jingfeng <sui.jingfeng@linux.dev>
Link: https://patchwork.freedesktop.org/patch/msgid/20230720123950.543082-1-harshit.m.mogalapalli@oracle.com
parent b31f784f
...@@ -120,12 +120,14 @@ static int lsdc_pixel_pll_setup(struct lsdc_pixpll * const this) ...@@ -120,12 +120,14 @@ static int lsdc_pixel_pll_setup(struct lsdc_pixpll * const this)
struct lsdc_pixpll_parms *pparms; struct lsdc_pixpll_parms *pparms;
this->mmio = ioremap(this->reg_base, this->reg_size); this->mmio = ioremap(this->reg_base, this->reg_size);
if (IS_ERR_OR_NULL(this->mmio)) if (!this->mmio)
return -ENOMEM; return -ENOMEM;
pparms = kzalloc(sizeof(*pparms), GFP_KERNEL); pparms = kzalloc(sizeof(*pparms), GFP_KERNEL);
if (IS_ERR_OR_NULL(pparms)) if (!pparms) {
iounmap(this->mmio);
return -ENOMEM; return -ENOMEM;
}
pparms->ref_clock = LSDC_PLL_REF_CLK_KHZ; pparms->ref_clock = LSDC_PLL_REF_CLK_KHZ;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment