Skip to content

Commit 5baeb15

Browse files
RuffaloLavoisiergregkh
authored andcommitted
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>
1 parent 0bad577 commit 5baeb15

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

drivers/comedi/drivers/ni_routing/tools/convert_c_to_py.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,11 @@ int main(void)
140140
{
141141
FILE *fp = fopen("ni_values.py", "w");
142142

143+
if (fp == NULL) {
144+
fprintf(stderr, "Could not open file!");
145+
return -1;
146+
}
147+
143148
/* write route register values */
144149
fprintf(fp, "ni_route_values = {\n");
145150
for (int i = 0; ni_all_route_values[i]; ++i)

0 commit comments

Comments
 (0)