<div dir="auto">New issue from Coveriry. <div dir="auto"><br></div><div dir="auto">I vaguely recall that JFFS2 uses dynamic checks for things that static would work and Coveriry spots the dead code</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">---------- Forwarded message ---------<br>From: <span dir="auto"><<a href="mailto:scan-admin@coverity.com">scan-admin@coverity.com</a>></span><br>Date: Sun, Mar 19, 2023, 10:59 PM<br>Subject: New Defects reported by Coverity Scan for RTEMS<br>To:  <<a href="mailto:build@rtems.org">build@rtems.org</a>><br></div><br><br>Hi,<br>
<br>
Please find the latest report on new defect(s) introduced to RTEMS found with Coverity Scan.<br>
<br>
4 new defect(s) introduced to RTEMS found with Coverity Scan.<br>
<br>
<br>
New defect(s) Reported-by: Coverity Scan<br>
Showing 4 of 4 defect(s)<br>
<br>
<br>
** CID 1523448:  Control flow issues  (DEADCODE)<br>
/cpukit/libfs/src/jffs2/src/gc.c: 137 in jffs2_garbage_collect_pass()<br>
<br>
<br>
________________________________________________________________________________________________________<br>
*** CID 1523448:  Control flow issues  (DEADCODE)<br>
/cpukit/libfs/src/jffs2/src/gc.c: 137 in jffs2_garbage_collect_pass()<br>
131             struct jffs2_raw_node_ref *raw;<br>
132             uint32_t gcblock_dirty;<br>
133             int ret = 0, inum, nlink;<br>
134             int xattr = 0;<br>
135     <br>
136             if (mutex_lock_interruptible(&c->alloc_sem))<br>
>>>     CID 1523448:  Control flow issues  (DEADCODE)<br>
>>>     Execution cannot reach this statement: "return -4;".<br>
137                     return -EINTR;<br>
138     <br>
139     <br>
140             for (;;) {<br>
141                     /* We can't start doing GC until we've finished checking<br>
142                        the node CRCs etc. */<br>
<br>
** CID 1523447:  Null pointer dereferences  (FORWARD_NULL)<br>
/cpukit/libfs/src/jffs2/src/fs-rtems.c: 1370 in rtems_jffs2_initialize()<br>
<br>
<br>
________________________________________________________________________________________________________<br>
*** CID 1523447:  Null pointer dereferences  (FORWARD_NULL)<br>
/cpukit/libfs/src/jffs2/src/fs-rtems.c: 1370 in rtems_jffs2_initialize()<br>
1364            } else {<br>
1365                    err = -ENOMEM;<br>
1366            }<br>
1367     <br>
1368            sb = &fs_info->sb;<br>
1369            c = JFFS2_SB_INFO(sb);<br>
>>>     CID 1523447:  Null pointer dereferences  (FORWARD_NULL)<br>
>>>     Dereferencing null pointer "c".<br>
1370            c->mtd = NULL;<br>
1371     <br>
1372            if (err == 0) {<br>
1373                    rtems_recursive_mutex_init(&sb->s_mutex, RTEMS_FILESYSTEM_TYPE_JFFS2);<br>
1374            }<br>
1375     <br>
<br>
** CID 1330065:  Incorrect expression  (PW.ASSIGN_WHERE_COMPARE_MEANT)<br>
/cpukit/libfs/src/jffs2/src/wbuf.c: 651 in ()<br>
<br>
<br>
________________________________________________________________________________________________________<br>
*** CID 1330065:  Incorrect expression  (PW.ASSIGN_WHERE_COMPARE_MEANT)<br>
/cpukit/libfs/src/jffs2/src/wbuf.c: 651 in ()<br>
645                     goto wfail;<br>
646             } else if (retlen != c->wbuf_pagesize) {<br>
647                     pr_warn("jffs2_flush_wbuf(): Write was short: %zd instead of %d\n",<br>
648                             retlen, c->wbuf_pagesize);<br>
649                     ret = -EIO;<br>
650                     goto wfail;<br>
>>>     CID 1330065:  Incorrect expression  (PW.ASSIGN_WHERE_COMPARE_MEANT)<br>
>>>     use of "=" where "==" may have been intended<br>
651             } else if ((ret = jffs2_verify_write(c, c->wbuf, c->wbuf_ofs))) {<br>
652             wfail:<br>
653                     jffs2_wbuf_recover(c);<br>
654     <br>
655                     return ret;<br>
656             }<br>
<br>
** CID 100676:  Resource leaks  (RESOURCE_LEAK)<br>
/cpukit/libfs/src/jffs2/src/scan.c: 290 in jffs2_scan_medium()<br>
<br>
<br>
________________________________________________________________________________________________________<br>
*** CID 100676:  Resource leaks  (RESOURCE_LEAK)<br>
/cpukit/libfs/src/jffs2/src/scan.c: 290 in jffs2_scan_medium()<br>
284             if (buf_size)<br>
285                     kfree(flashbuf);<br>
286     #ifndef __ECOS<br>
287             else<br>
288                     mtd_unpoint(c->mtd, 0, c->mtd->size);<br>
289     #endif<br>
>>>     CID 100676:  Resource leaks  (RESOURCE_LEAK)<br>
>>>     Variable "flashbuf" going out of scope leaks the storage it points to.<br>
290             return ret;<br>
291     }<br>
292     <br>
293     static int jffs2_fill_scan_buf(struct jffs2_sb_info *c, void *buf,<br>
294                                    uint32_t ofs, uint32_t len)<br>
295     {<br>
<br>
<br>
________________________________________________________________________________________________________<br>
To view the defects in Coverity Scan visit, <a href="https://u15810271.ct.sendgrid.net/ls/click?upn=HRESupC-2F2Czv4BOaCWWCy7my0P0qcxCbhZ31OYv50ypUUzi-2FdSNmuyRB7BEFT8xQ4-2B8hpujh0hTgQljRGId4Dg-3D-3D4ud5_EU3W9teASMK00lBXX9WT4lsogDrkCcNZLvg-2FVxwAXMpnugfe7VtmjlezAUiUAqURm-2BYADlhnMIumDCuBe7mGT9aB8TE9cxvKFYrBHVJ7mgUGDbfjluxq0RzsXGFS9SkOWyeEfvDu1fFzYW3HwPYe1Rb-2FBCAMDNLGqgmVE-2Bb4qg5R5mDe6-2FFbWF4SiJvT-2FGVjdNh1OVArH-2Ff8IlRB6Y43MQ-3D-3D" rel="noreferrer noreferrer" target="_blank">https://u15810271.ct.sendgrid.net/ls/click?upn=HRESupC-2F2Czv4BOaCWWCy7my0P0qcxCbhZ31OYv50ypUUzi-2FdSNmuyRB7BEFT8xQ4-2B8hpujh0hTgQljRGId4Dg-3D-3D4ud5_EU3W9teASMK00lBXX9WT4lsogDrkCcNZLvg-2FVxwAXMpnugfe7VtmjlezAUiUAqURm-2BYADlhnMIumDCuBe7mGT9aB8TE9cxvKFYrBHVJ7mgUGDbfjluxq0RzsXGFS9SkOWyeEfvDu1fFzYW3HwPYe1Rb-2FBCAMDNLGqgmVE-2Bb4qg5R5mDe6-2FFbWF4SiJvT-2FGVjdNh1OVArH-2Ff8IlRB6Y43MQ-3D-3D</a><br>
<br>
_______________________________________________<br>
build mailing list<br>
<a href="mailto:build@rtems.org" target="_blank" rel="noreferrer">build@rtems.org</a><br>
<a href="http://lists.rtems.org/mailman/listinfo/build" rel="noreferrer noreferrer" target="_blank">http://lists.rtems.org/mailman/listinfo/build</a><br>
</div>