Skip to content

Commit

Permalink
comedi: ni_routing: tools: Check when the file could not be opened
Browse files Browse the repository at this point in the history
- 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>
  • Loading branch information
RuffaloLavoisier authored and gregkh committed Sep 11, 2024
1 parent 0bad577 commit 5baeb15
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions drivers/comedi/drivers/ni_routing/tools/convert_c_to_py.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 5baeb15

Please sign in to comment.