Skip to content

Commit

Permalink
osd: null pointer risk protect
Browse files Browse the repository at this point in the history
PD#151241: null pointer risk protect

driver defect clean up:
torvalds#284

Change-Id: I05ffb3df451b0f62de0ef00a688edc6bc33b1964
Signed-off-by: Pengcheng Chen <[email protected]>
  • Loading branch information
Pengcheng Chen authored and akiernan committed Nov 4, 2022
1 parent 3925ab4 commit e13fcea
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions drivers/amlogic/media/osd/osd_fb.c
Original file line number Diff line number Diff line change
Expand Up @@ -1277,7 +1277,7 @@ static int osd_mmap(struct fb_info *info, struct vm_area_struct *vma)
fbdev->fb_mem_vaddr = fb_rmem_vaddr[fb_index];
if (!fbdev->fb_mem_vaddr) {
osd_log_err("failed to ioremap frame buffer\n");
ret = -ENOMEM;
return -ENOMEM;
}
osd_log_info("Frame buffer memory assigned at");
osd_log_info(" %d, phy: 0x%p, vir:0x%p, size=%dK\n\n",
Expand Down Expand Up @@ -1318,7 +1318,8 @@ static int osd_mmap(struct fb_info *info, struct vm_area_struct *vma)
osd_log_info("---------------clear fb%d memory %p\n",
fb_index, fbdev->fb_mem_vaddr);
set_logo_loaded();
memset(fbdev->fb_mem_vaddr, 0x0, fbdev->fb_len);
if (fbdev->fb_mem_vaddr)
memset(fbdev->fb_mem_vaddr, 0x0, fbdev->fb_len);
if (fb_index == DEV_OSD0 && osd_get_afbc()) {
for (j = 1; j < OSD_MAX_BUF_NUM; j++) {
osd_log_info(
Expand All @@ -1334,10 +1335,10 @@ static int osd_mmap(struct fb_info *info, struct vm_area_struct *vma)
* 1. the big buffer ion alloc
* 2. reserved memory
*/

memset(fb_rmem_vaddr[fb_index],
0x0,
fb_rmem_size[fb_index]);
if (fb_rmem_vaddr[fb_index])
memset(fb_rmem_vaddr[fb_index],
0x0,
fb_rmem_size[fb_index]);
}
/* setup osd if not logo layer */
osddev_setup(fbdev);
Expand Down

0 comments on commit e13fcea

Please sign in to comment.