lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 28 Jan 2019 11:53:54 +0200
From:   Andy Shevchenko <andy.shevchenko@...il.com>
To:     Heikki Krogerus <heikki.krogerus@...ux.intel.com>
Cc:     Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Chen Yu <chenyu56@...wei.com>, Jun Li <jun.li@....com>,
        Hans de Goede <hdegoede@...hat.com>,
        USB <linux-usb@...r.kernel.org>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 4/8] usb: typec: mux: Find the muxes by also matching
 against the device node

On Fri, Jan 25, 2019 at 3:17 PM Heikki Krogerus
<heikki.krogerus@...ux.intel.com> wrote:
>
> When the connections are defined in firmware, struct
> device_connection will have the fwnode member pointing to
> the device node (struct fwnode_handle) of the requested
> device, and the endpoint will not be used at all in that
> case.

>  static void *typec_mux_match(struct device_connection *con, int ep, void *data)
>  {
> +       const struct typec_altmode_desc *desc = data;
>         struct typec_mux *mux;

> +       bool match = !con->id;

I don't see how this assignment is used.

> +       size_t nval;
> +       u16 *val;
> +       int i;
> +
> +       if (!con->fwnode) {
> +               list_for_each_entry(mux, &mux_list, entry)
> +                       if (!strcmp(con->endpoint[ep], dev_name(mux->dev)))
> +                               return mux;
> +               return ERR_PTR(-EPROBE_DEFER);
> +       }
> +
> +       if (match)
> +               goto find_mux;
> +
> +       /* Accessory Mode muxes */
> +       if (!desc) {
> +               match = fwnode_property_present(con->fwnode, "accessory");
> +               if (match)
> +                       goto find_mux;
> +               return NULL;
> +       }
> +
> +       /* Alternate Mode muxes */
> +       nval = fwnode_property_read_u16_array(con->fwnode, "svid", NULL, 0);
> +       if (nval <= 0)
> +               return NULL;
> +
> +       val = kcalloc(nval, sizeof(*val), GFP_KERNEL);
> +       if (!val)
> +               return ERR_PTR(-ENOMEM);
> +
> +       nval = fwnode_property_read_u16_array(con->fwnode, "svid", val, nval);
> +       if (nval < 0) {
> +               kfree(val);
> +               return ERR_PTR(nval);
> +       }
> +
> +       for (i = 0; i < nval; i++) {
> +               match = val[i] == desc->svid;
> +               if (match) {
> +                       kfree(val);
> +                       goto find_mux;
> +               }
> +       }
> +       kfree(val);
> +       return NULL;
>
> +find_mux:
>         list_for_each_entry(mux, &mux_list, entry)
> -               if (!strcmp(con->endpoint[ep], dev_name(mux->dev)))
> +               if (dev_fwnode(mux->dev) == con->fwnode)
>                         return mux;
>
> -       /*
> -        * We only get called if a connection was found, tell the caller to
> -        * wait for the switch to show up.
> -        */
> -       return ERR_PTR(-EPROBE_DEFER);
> +       return match ? ERR_PTR(-EPROBE_DEFER) : NULL;
>  }

-- 
With Best Regards,
Andy Shevchenko

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ