diff options
author | Ruffalo Lavoisier <ruffalolavoisier@gmail.com> | 2024-09-07 05:30:25 +0900 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2024-09-11 16:03:28 +0200 |
commit | 5baeb157b341b1d26a5815aeaa4d3bb9e0444fda (patch) | |
tree | e8c363010f9b2abcb8804640d3aad33e18478199 /drivers/comedi | |
parent | 0bad57708d7c16a409a2770e9e8c477a30b257c0 (diff) |
comedi: ni_routing: tools: Check when the file could not be opened
- After fopen check NULL before using the file pointer use
Signed-off-by: Ruffalo Lavoisier <RuffaloLavoisier@gmail.com>
Link: https://lore.kernel.org/r/20240906203025.89588-1-RuffaloLavoisier@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/comedi')
-rw-r--r-- | drivers/comedi/drivers/ni_routing/tools/convert_c_to_py.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/comedi/drivers/ni_routing/tools/convert_c_to_py.c b/drivers/comedi/drivers/ni_routing/tools/convert_c_to_py.c index d55521b5bdcb..892a66b2cea6 100644 --- a/drivers/comedi/drivers/ni_routing/tools/convert_c_to_py.c +++ b/drivers/comedi/drivers/ni_routing/tools/convert_c_to_py.c @@ -140,6 +140,11 @@ int main(void) { FILE *fp = fopen("ni_values.py", "w"); + if (fp == NULL) { + fprintf(stderr, "Could not open file!"); + return -1; + } + /* write route register values */ fprintf(fp, "ni_route_values = {\n"); for (int i = 0; ni_all_route_values[i]; ++i) |