Bug 188801 - Function bdisp_debugfs_create() returns improper values on failures.
Summary: Function bdisp_debugfs_create() returns improper values on failures.
Status: RESOLVED CODE_FIX
Alias: None
Product: Drivers
Classification: Unclassified
Component: Video(Other) (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: drivers_video-other
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-11-25 10:59 UTC by bianpan
Modified: 2017-05-11 23:56 UTC (History)
0 users

See Also:
Kernel Version: linux-4.9-rc6
Subsystem:
Regression: No
Bisected commit-id:


Attachments
The patch fixes the bug (1.02 KB, patch)
2017-05-11 23:56 UTC, bianpan
Details | Diff

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.

Note You need to log in before you can comment on or make changes to this bug.