devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Sergio Paracuellos <sergio.paracuellos@gmail.com>
Cc: Woojung.Huh@microchip.com, Andrew Lunn <andrew@lunn.ch>,
	Florian Fainelli <f.fainelli@gmail.com>,
	vivien.didelot@savoirfairelinux.com, netdev@vger.kernel.org,
	driverdev-devel@linuxdriverproject.org,
	UNGLinuxDriver@microchip.com,
	"open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS"
	<devicetree@vger.kernel.org>,
	davem@davemloft.net
Subject: Re: [PATCH 1/2] net: dsa: ksz9477: add I2C managed mode support
Date: Mon, 17 Dec 2018 22:11:14 +0300	[thread overview]
Message-ID: <20181217191114.GF19692@kadam> (raw)
In-Reply-To: <CAMhs-H-MjMnS+S9v9-O2=Cz+e-6xp3ZYmDvy-VVif+fKNRaSnw@mail.gmail.com>

On Mon, Dec 17, 2018 at 07:22:51PM +0100, Sergio Paracuellos wrote:
> > > +static int ksz_i2c_write(struct ksz_device *dev, u32 reg, u8 *val,
> > > +                      unsigned int len)
> > > +{
> > > +     struct i2c_client *client = dev->priv;
> > > +     unsigned int cnt = len;
> > > +     int i = 0;
> > > +     u8 txb[4];
> > > +
> > > +     do {
> > > +             txb[i++] = (u8)(*val >> (8 * (cnt - 1)));
> >                                               ^^^^^^^
> >
> > Can "cnt" be zero from ksz_i2c_set()?  If so this loop will corrupt
> > memory.
> 
> This get and set interface seems to be introduced recently but it is
> not being used yet, so
> in this moment the answer is not. For me, there is no sense in call
> 'set' with no len. Should
> I add a check for zero len and return EINVAL just in case?
> 

Yes, please.

> > > +static int ksz_i2c_probe(struct i2c_client *client,
> > > +                      const struct i2c_device_id *id)
> > > +{
> > > +     struct ksz_device *dev;
> > > +     int ret;
> > > +
> > > +     dev = ksz_switch_alloc(&client->dev, &ksz_i2c_ops, client);
> > > +     if (!dev)
> > > +             return -ENOMEM;
> > > +
> > > +     if (client->dev.platform_data)
> > > +             dev->pdata = client->dev.platform_data;
> > > +
> > > +     i2c_set_clientdata(client, dev);
> > > +
> > > +     ret = ksz9477_switch_register(dev);
> > > +     if (ret) {
> > > +             dev_err(&client->dev, "registering switch (ret: %d)\n", ret);
> >
> >
> > free dev on this error path?
> 
> Internally all of this are using devm_* funcions, so I think is there
> is no need to free anything. Also, the
> spi managed driver for this does nothing also about this.

You're right.  My bad.  I should have looked at this.

regards,
dan carpenter

  reply	other threads:[~2018-12-17 19:11 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-16  7:57 [PATCH 1/2] net: dsa: ksz9477: add I2C managed mode support Sergio Paracuellos
2018-12-16  7:57 ` [PATCH 2/2] dt-bindings: net: dsa: ksz9477: add sample of switch bindings managed in i2c mode Sergio Paracuellos
2018-12-16  8:18   ` Andrew Lunn
2018-12-16  8:32     ` Sergio Paracuellos
2018-12-16  8:15 ` [PATCH 1/2] net: dsa: ksz9477: add I2C managed mode support Andrew Lunn
2018-12-16  8:35   ` Sergio Paracuellos
2018-12-16  8:44     ` Andrew Lunn
2018-12-17  6:54 ` Dan Carpenter
2018-12-17 18:22   ` Sergio Paracuellos
2018-12-17 19:11     ` Dan Carpenter [this message]
2018-12-17 20:46       ` Sergio Paracuellos

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181217191114.GF19692@kadam \
    --to=dan.carpenter@oracle.com \
    --cc=UNGLinuxDriver@microchip.com \
    --cc=Woojung.Huh@microchip.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=devicetree@vger.kernel.org \
    --cc=driverdev-devel@linuxdriverproject.org \
    --cc=f.fainelli@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=sergio.paracuellos@gmail.com \
    --cc=vivien.didelot@savoirfairelinux.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).