mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-21 01:54:51 +08:00
drm/sprd: check the platform_get_resource() return value
platform_get_resource() may fail and return NULL, so check it's value before using it. Reported-by: Zou Wei <zou_wei@huawei.com> Signed-off-by: Kevin Tang <kevin3.tang@gmail.com> Reviewed-by: Javier Martinez Canillas <javierm@redhat.com> Acked-by: Thomas Zimmermann <tzimmermann@suse.de> Link: https://lore.kernel.org/all/20220117084156.9338-1-kevin3.tang@gmail.com v1 -> v2: - new patch
This commit is contained in:
parent
8668658aeb
commit
73792e6e66
@ -790,6 +790,11 @@ static int sprd_dpu_context_init(struct sprd_dpu *dpu,
|
||||
int ret;
|
||||
|
||||
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
||||
if (!res) {
|
||||
dev_err(dev, "failed to get I/O resource\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
ctx->base = devm_ioremap(dev, res->start, resource_size(res));
|
||||
if (!ctx->base) {
|
||||
dev_err(dev, "failed to map dpu registers\n");
|
||||
|
@ -907,6 +907,11 @@ static int sprd_dsi_context_init(struct sprd_dsi *dsi,
|
||||
struct resource *res;
|
||||
|
||||
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
||||
if (!res) {
|
||||
dev_err(dev, "failed to get I/O resource\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
ctx->base = devm_ioremap(dev, res->start, resource_size(res));
|
||||
if (!ctx->base) {
|
||||
drm_err(dsi->drm, "failed to map dsi host registers\n");
|
||||
|
Loading…
Reference in New Issue
Block a user