* [bug report] of: unittest: Add phandle remapping test
@ 2019-03-04 13:23 Dan Carpenter
0 siblings, 0 replies; only message in thread
From: Dan Carpenter @ 2019-03-04 13:23 UTC (permalink / raw)
To: stephen.boyd; +Cc: devicetree
Hello Stephen Boyd,
The patch 357aa4b61c82: "of: unittest: Add phandle remapping test"
from Jan 30, 2018, leads to the following static checker warning:
drivers/of/unittest.c:567 of_unittest_parse_phandle_with_args_map()
error: potential zalloc NULL dereference: 'args.np'
drivers/of/unittest.c
511 for (i = 0; i < 8; i++) {
512 bool passed = true;
513
514 memset(&args, 0, sizeof(args));
^^^^^
args.np set to NULL.
515 rc = of_parse_phandle_with_args_map(np, "phandle-list",
516 "phandle", i, &args);
^^^^^
A bunch of error paths don't set args.np.
517
518 /* Test the values from tests-phandle.dtsi */
519 switch (i) {
520 case 0:
521 passed &= !rc;
522 passed &= (args.np == p1);
523 passed &= (args.args_count == 1);
524 passed &= (args.args[0] == 1);
525 break;
526 case 1:
527 passed &= !rc;
528 passed &= (args.np == p3);
529 passed &= (args.args_count == 3);
530 passed &= (args.args[0] == 2);
531 passed &= (args.args[1] == 5);
532 passed &= (args.args[2] == 3);
533 break;
534 case 2:
535 passed &= (rc == -ENOENT);
536 break;
537 case 3:
538 passed &= !rc;
539 passed &= (args.np == p0);
540 passed &= (args.args_count == 0);
541 break;
542 case 4:
543 passed &= !rc;
544 passed &= (args.np == p1);
545 passed &= (args.args_count == 1);
546 passed &= (args.args[0] == 3);
547 break;
548 case 5:
549 passed &= !rc;
550 passed &= (args.np == p0);
551 passed &= (args.args_count == 0);
552 break;
553 case 6:
554 passed &= !rc;
555 passed &= (args.np == p2);
556 passed &= (args.args_count == 2);
557 passed &= (args.args[0] == 15);
558 passed &= (args.args[1] == 0x20);
559 break;
560 case 7:
561 passed &= (rc == -ENOENT);
562 break;
563 default:
564 passed = false;
565 }
566
--> 567 unittest(passed, "index %i - data error on node %s rc=%i\n",
568 i, args.np->full_name, rc);
^^^^^^^^^^^^^^^^^^
Potential NULL dereference.
569 }
570
regards,
dan carpenter
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2019-03-04 13:23 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-03-04 13:23 [bug report] of: unittest: Add phandle remapping test Dan Carpenter
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.