Changeset c0ea739 in mainline
- Timestamp:
- 2018-11-09T22:03:24Z (6 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- b9a2725
- Parents:
- 88e43bc
- git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-11-08 01:00:44)
- git-committer:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-11-09 22:03:24)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/sysinfo/sysinfo.c
r88e43bc rc0ea739 205 205 *psubtree = 206 206 (sysinfo_item_t *) slab_alloc(sysinfo_item_cache, 0); 207 assert(*psubtree); 207 if (!*psubtree) 208 return NULL; 208 209 209 210 /* Fill in item name up to the delimiter */ 210 211 (*psubtree)->name = str_ndup(name, i); 211 assert((*psubtree)->name); 212 if (!(*psubtree)->name) { 213 slab_free(sysinfo_item_cache, *psubtree); 214 return NULL; 215 } 212 216 213 217 /* Create subtree items */ 214 218 if (name[i] == '.') { 215 219 (*psubtree)->subtree_type = SYSINFO_SUBTREE_TABLE; 216 returnsysinfo_create_path(name + i + 1,220 sysinfo_item_t *item = sysinfo_create_path(name + i + 1, 217 221 &((*psubtree)->subtree.table)); 222 if (!item) { 223 free((*psubtree)->name); 224 slab_free(sysinfo_item_cache, *psubtree); 225 } 226 return item; 218 227 } 219 228 … … 272 281 sysinfo_item_t *item = 273 282 (sysinfo_item_t *) slab_alloc(sysinfo_item_cache, 0); 274 assert(item); 283 if (!item) 284 return NULL; 275 285 276 286 cur->next = item; … … 278 288 /* Fill in item name up to the delimiter */ 279 289 item->name = str_ndup(name, i); 280 assert(item->name); 290 if (!item->name) { 291 slab_free(sysinfo_item_cache, item); 292 return NULL; 293 } 281 294 282 295 /* Create subtree items */ 283 296 if (name[i] == '.') { 284 297 item->subtree_type = SYSINFO_SUBTREE_TABLE; 285 return sysinfo_create_path(name + i + 1, 286 &(item->subtree.table)); 298 sysinfo_item_t *sub = sysinfo_create_path( 299 name + i + 1, &(item->subtree.table)); 300 if (!sub) { 301 free(item->name); 302 slab_free(sysinfo_item_cache, item); 303 return NULL; 304 } 305 return sub; 287 306 } 288 307 … … 318 337 item->val_type = SYSINFO_VAL_VAL; 319 338 item->val.val = val; 339 } else { 340 printf("Could not set sysinfo item %s.\n", name); 320 341 } 321 342 … … 350 371 item->val.data.data = data; 351 372 item->val.data.size = size; 373 } else { 374 printf("Could not set sysinfo item %s.\n", name); 352 375 } 353 376 … … 378 401 item->val.gen_val.fn = fn; 379 402 item->val.gen_val.data = data; 403 } else { 404 printf("Could not set sysinfo item %s.\n", name); 380 405 } 381 406 … … 411 436 item->val.gen_data.fn = fn; 412 437 item->val.gen_data.data = data; 438 } else { 439 printf("Could not set sysinfo item %s.\n", name); 413 440 } 414 441 … … 434 461 if (item != NULL) 435 462 item->val_type = SYSINFO_VAL_UNDEFINED; 463 else 464 printf("Could not set sysinfo item %s.\n", name); 436 465 437 466 mutex_unlock(&sysinfo_lock); … … 466 495 item->subtree.generator.fn = fn; 467 496 item->subtree.generator.data = data; 497 } else { 498 printf("Could not set sysinfo item %s.\n", name); 468 499 } 469 500
Note:
See TracChangeset
for help on using the changeset viewer.