Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: f39db26c5428 ("drm: Add kms driver for loongson display controller")
Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
Reviewed-by: Sui Jingfeng <suijingfeng@loongson.cn>
Signed-off-by: Sui Jingfeng <sui.jingfeng@linux.dev>
Link: https://patchwork.freedesktop.org/patch/msgid/20230720123950.543082-1-harshit.m.mogalapalli@oracle.com

authored by

Harshit Mogalapalli and committed by
Sui Jingfeng
5976a28b b31f784f

+4 -2
+4 -2
drivers/gpu/drm/loongson/lsdc_pixpll.c
··· 120 120 struct lsdc_pixpll_parms *pparms; 121 121 122 122 this->mmio = ioremap(this->reg_base, this->reg_size); 123 - if (IS_ERR_OR_NULL(this->mmio)) 123 + if (!this->mmio) 124 124 return -ENOMEM; 125 125 126 126 pparms = kzalloc(sizeof(*pparms), GFP_KERNEL); 127 - if (IS_ERR_OR_NULL(pparms)) 127 + if (!pparms) { 128 + iounmap(this->mmio); 128 129 return -ENOMEM; 130 + } 129 131 130 132 pparms->ref_clock = LSDC_PLL_REF_CLK_KHZ; 131 133