Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Ruffalo Lavoisier and committed by
Greg Kroah-Hartman
5baeb157 0bad5770

+5
+5
drivers/comedi/drivers/ni_routing/tools/convert_c_to_py.c
··· 140 140 { 141 141 FILE *fp = fopen("ni_values.py", "w"); 142 142 143 + if (fp == NULL) { 144 + fprintf(stderr, "Could not open file!"); 145 + return -1; 146 + } 147 + 143 148 /* write route register values */ 144 149 fprintf(fp, "ni_route_values = {\n"); 145 150 for (int i = 0; ni_all_route_values[i]; ++i)