From: Andrew Lunn <[email protected]>
Date: Thu, 14 Apr 2016 01:59:54 +0200
> @@ -3178,6 +3178,7 @@ int mv88e6xxx_probe(struct mdio_device *mdiodev, struct
> dsa_switch_driver *ops,
> struct mv88e6xxx_priv_state *ps;
> struct dsa_switch *ds;
> const char *name;
> + int err;
>
> ds = devm_kzalloc(dev, sizeof(*ds) + sizeof(*ps), GFP_KERNEL);
> if (!ds)
> @@ -3199,6 +3200,17 @@ int mv88e6xxx_probe(struct mdio_device *mdiodev,
> struct dsa_switch_driver *ops,
> return -ENODEV;
> }
>
> + ps->reset = devm_gpiod_get(&mdiodev->dev, "reset", GPIOD_ASIS);
> + err = PTR_ERR(ps->reset);
> + if (err) {
> + if (err == -ENOENT) {
> + /* Optional, so not an error */
> + ps->reset = NULL;
> + } else {
> + return err;
> + }
> + }
PTR_ERR() just casts the pointer into an integer, regardless of it's
value, and regardless of whether it is an error code or a real pointer
successfully returned from devm_gpiod_get().
So I don't think this code is correct.
You need an IS_ERR() check in there somewhere.