[bug report] usb: typec: tcpm: Add callbacks to mitigate wakeups due to contaminant

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello Badhri Jagan Sridharan,

Commit 599f008c257d ("usb: typec: tcpm: Add callbacks to mitigate
wakeups due to contaminant") from Jan 14, 2023 (linux-next), leads to
the following Smatch static checker warning:

	drivers/usb/typec/tcpm/tcpm.c:4620 run_state_machine()
	error: we previously assumed 'port->tcpc->check_contaminant' could be null (see line 4607)

drivers/usb/typec/tcpm/tcpm.c
    4600 static void run_state_machine(struct tcpm_port *port)
    4601 {
    4602         int ret;
    4603         enum typec_pwr_opmode opmode;
    4604         unsigned int msecs;
    4605         enum tcpm_state upcoming_state;
    4606 
    4607         if (port->tcpc->check_contaminant && port->state != CHECK_CONTAMINANT)

Assume that ->check_contaminant is NULL and port->state == CHECK_CONTAMINANT

    4608                 port->potential_contaminant = ((port->enter_state == SRC_ATTACH_WAIT &&
    4609                                                 port->state == SRC_UNATTACHED) ||
    4610                                                (port->enter_state == SNK_ATTACH_WAIT &&
    4611                                                 port->state == SNK_UNATTACHED) ||
    4612                                                (port->enter_state == SNK_DEBOUNCED &&
    4613                                                 port->state == SNK_UNATTACHED));
    4614 
    4615         port->enter_state = port->state;
    4616         switch (port->state) {
    4617         case TOGGLING:
    4618                 break;
    4619         case CHECK_CONTAMINANT:
--> 4620                 port->tcpc->check_contaminant(port->tcpc);

then we're in case CHECK_CONTAMINANT and the function pointer is NULL.

    4621                 break;
    4622         /* SRC states */
    4623         case SRC_UNATTACHED:
    4624                 if (!port->non_pd_role_swap)
    4625                         tcpm_swap_complete(port, -ENOTCONN);
    4626                 tcpm_src_detach(port);
    4627                 if (port->potential_contaminant) {
    4628                         tcpm_set_state(port, CHECK_CONTAMINANT, 0);
    4629                         break;
    4630                 }
    4631                 if (tcpm_start_toggling(port, tcpm_rp_cc(port))) {
    4632                         tcpm_set_state(port, TOGGLING, 0);
    4633                         break;

regards,
dan carpenter




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux