Bug 188801

Summary: Function bdisp_debugfs_create() returns improper values on failures.
Product: Drivers Reporter: bianpan (bianpan2010)
Component: Video(Other)Assignee: drivers_video-other
Status: RESOLVED CODE_FIX    
Severity: normal    
Priority: P1    
Hardware: All   
OS: Linux   
Kernel Version: linux-4.9-rc6 Subsystem:
Regression: No Bisected commit-id:
Attachments: The patch fixes the bug

Description bianpan 2016-11-25 10:59:43 UTC
Function bdisp_debugfs_create() is defined in file drivers/media/platform/sti/bdisp/bdisp-debug.c. The control flow jumps to label "err", but returns 0. By reviewing the source code of the caller of bdisp_debugfs_create(), return value 0 indicates success, which is contrary to the fact. Maybe it is better to use "return -ENOMEM" instead of "return 0" at line 680. Codes related to this bug are shown as below.

bdisp_debugfs_create @@ drivers/media/platform/sti/bdisp/bdisp-debug.c
652 int bdisp_debugfs_create(struct bdisp_dev *bdisp)
653 {
654     char dirname[16];
655 
656     snprintf(dirname, sizeof(dirname), "%s%d", BDISP_NAME, bdisp->id);
657     bdisp->dbg.debugfs_entry = debugfs_create_dir(dirname, NULL);
658     if (!bdisp->dbg.debugfs_entry)
659         goto err;
660 
661     if (!bdisp_dbg_create_entry(regs))
662         goto err;
663 
664     if (!bdisp_dbg_create_entry(last_nodes))
665         goto err;
666 
667     if (!bdisp_dbg_create_entry(last_nodes_raw))
668         goto err;
669 
670     if (!bdisp_dbg_create_entry(last_request))
671         goto err;
672 
673     if (!bdisp_dbg_create_entry(perf))
674         goto err;
675 
676     return 0;
677 
678 err:
679     bdisp_debugfs_remove(bdisp);
680     return 0;     // return -ENOMEM?
681 }

Thanks very much!
Comment 1 bianpan 2017-05-11 23:56:11 UTC
Created attachment 256421 [details]
The patch fixes the bug

The patch has been merged into the latest version of the Linux kernel. So I will close the bug.