Flash device - Fwd: New Defects reported by Coverity Scan for RTEMS

Joel Sherrill joel at rtems.org
Tue May 16 11:41:57 UTC 2023


At least one of them is clear how to fix.

---------- Forwarded message ---------
From: <scan-admin at coverity.com>
Date: Tue, May 16, 2023, 12:57 AM
Subject: New Defects reported by Coverity Scan for RTEMS
To: <build at rtems.org>


Hi,

Please find the latest report on new defect(s) introduced to RTEMS found
with Coverity Scan.

2 new defect(s) introduced to RTEMS found with Coverity Scan.


New defect(s) Reported-by: Coverity Scan
Showing 2 of 2 defect(s)


** CID 1530126:  Resource leaks  (RESOURCE_LEAK)
/cpukit/libmisc/shell/main_flashdev.c: 184 in flashdev_shell_read()


________________________________________________________________________________________________________
*** CID 1530126:  Resource leaks  (RESOURCE_LEAK)
/cpukit/libmisc/shell/main_flashdev.c: 184 in flashdev_shell_read()
178       }
179
180       /* Create a buffer to read into */
181       buffer = calloc((bytes + bytes%4), 1);
182       if (buffer == NULL) {
183         printf("Failed to allocate read buffer\n");
>>>     CID 1530126:  Resource leaks  (RESOURCE_LEAK)
>>>     Handle variable "fd" going out of scope leaks the handle.
184         return -1;
185       }
186
187       /* Read into buffer */
188       status = read(fd, buffer, bytes);
189       if (status == -1) {

** CID 1530125:    (FORWARD_NULL)


________________________________________________________________________________________________________
*** CID 1530125:    (FORWARD_NULL)
/cpukit/libmisc/shell/main_flashdev.c: 105 in rtems_flashdev_shell_main()
99             return flashdev_shell_page_off(dev_path, argc, &argv[i]);
100           case ('i'):
101             /* Page info by index */
102             return flashdev_shell_page_idx(dev_path, argc, &argv[i]);
103           case ('p'):
104             /* Page count */
>>>     CID 1530125:    (FORWARD_NULL)
>>>     Passing null pointer "dev_path" to "flashdev_shell_pg_count", which
dereferences it.
105             return flashdev_shell_pg_count(dev_path);
106           case ('b'):
107             /* Write block size */
108             return flashdev_shell_wb_size(dev_path);
109           case ('h'):
110           default:
/cpukit/libmisc/shell/main_flashdev.c: 96 in rtems_flashdev_shell_main()
90             return flashdev_shell_erase(dev_path, argc, &argv[i]);
91           case ('t'):
92             /* Flash Type */
93             return flashdev_shell_type(dev_path);
94           case ('d'):
95             /* JEDEC Id */
>>>     CID 1530125:    (FORWARD_NULL)
>>>     Passing null pointer "dev_path" to "flashdev_shell_jedecid", which
dereferences it.
96             return flashdev_shell_jedecid(dev_path);
97           case ('o'):
98             /* Page info by offset */
99             return flashdev_shell_page_off(dev_path, argc, &argv[i]);
100           case ('i'):
101             /* Page info by index */
/cpukit/libmisc/shell/main_flashdev.c: 108 in rtems_flashdev_shell_main()
102             return flashdev_shell_page_idx(dev_path, argc, &argv[i]);
103           case ('p'):
104             /* Page count */
105             return flashdev_shell_pg_count(dev_path);
106           case ('b'):
107             /* Write block size */
>>>     CID 1530125:    (FORWARD_NULL)
>>>     Passing null pointer "dev_path" to "flashdev_shell_wb_size", which
dereferences it.
108             return flashdev_shell_wb_size(dev_path);
109           case ('h'):
110           default:
111             /* Help */
112             printf(rtems_flashdev_shell_usage);
113             break;
/cpukit/libmisc/shell/main_flashdev.c: 93 in rtems_flashdev_shell_main()
87             return flashdev_shell_write(dev_path, argc, &argv[i]);
88           case ('e'):
89             /* Erase */
90             return flashdev_shell_erase(dev_path, argc, &argv[i]);
91           case ('t'):
92             /* Flash Type */
>>>     CID 1530125:    (FORWARD_NULL)
>>>     Passing null pointer "dev_path" to "flashdev_shell_type", which
dereferences it.
93             return flashdev_shell_type(dev_path);
94           case ('d'):
95             /* JEDEC Id */
96             return flashdev_shell_jedecid(dev_path);
97           case ('o'):
98             /* Page info by offset */


________________________________________________________________________________________________________
To view the defects in Coverity Scan visit,
https://u15810271.ct.sendgrid.net/ls/click?upn=HRESupC-2F2Czv4BOaCWWCy7my0P0qcxCbhZ31OYv50ypUUzi-2FdSNmuyRB7BEFT8xQ4-2B8hpujh0hTgQljRGId4Dg-3D-3DXEx5_EU3W9teASMK00lBXX9WT4lsogDrkCcNZLvg-2FVxwAXMpqJ0-2Bfnv2-2FSXUlg52TUkS4uxSk3QPG8iWcXRzrk-2B9RKzEXdImy7vPVPfobCitkPqycfORs5dqm5DRNtKzDWMe2v8pZfERgB4abKyzpcD14thNAda8IeCRimcHZTHa1TrkAIwnda90httchtDZlqlkvbTydvDbLO0dR2nGlQejj4Q-3D-3D

_______________________________________________
build mailing list
build at rtems.org
http://lists.rtems.org/mailman/listinfo/build
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/devel/attachments/20230516/121d64b2/attachment.htm>


More information about the devel mailing list