[LU-11030] Uninitialized variable use in fld_update_from_controller Created: 18/May/18 Updated: 18/May/18 |
|
| Status: | Open |
| Project: | Lustre |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Minor |
| Reporter: | Oleg Drokin | Assignee: | WC Triage |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Severity: | 3 |
| Rank (Obsolete): | 9223372036854775807 |
| Description |
|
In looks like we can use index variable without initialization in fld_update_from_controller: __u32 index;
...
rc = fld_name_to_index(fld->lsf_name, &index);
if (rc < 0)
RETURN(rc);
/* No need update fldb for MDT0 */
if (index == 0)
RETURN(0);
Now if we look into fld_name_to_index() it looks ok: int fld_name_to_index(const char *name, __u32 *index) { char *dash; int rc; ENTRY; CDEBUG(D_INFO, "get index from %s\n", name); dash = strrchr(name, '-'); if (dash == NULL) RETURN(-EINVAL); dash++; rc = target_name2index(dash, index, NULL); RETURN(rc); } As in we return negative value to caller if the index is not updated. But if we actually look inside target_name2index, we can see: if (strncmp(dash, "MDT", 3) == 0) rc = LDD_F_SV_TYPE_MDT; else if (strncmp(dash, "OST", 3) == 0) rc = LDD_F_SV_TYPE_OST; else return -EINVAL; dash += 3; if (strncmp(dash, "all", 3) == 0) { if (endptr != NULL) *endptr = dash + 3; return rc | LDD_F_SV_ALL; } so if we have 'all' literal after the dash - the index is not updated and we don't return an error. This needs to be handled one way or another. |