lkml.org 
[lkml]   [2017]   [Dec]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v5 04/15] soundwire: Add MIPI DisCo property helpers
On Mon, Dec 11, 2017 at 05:10:17PM +0100, Takashi Iwai wrote:
> On Wed, 06 Dec 2017 16:47:00 +0100,
> Vinod Koul wrote:
> >
> > +static int sdw_slave_read_dpn(struct sdw_slave *slave,
> > + struct sdw_dpn_prop *dpn, int count, int ports, char *type)
> > +{
> ....
> > + nval = fwnode_property_read_u32_array(node,
> > + "mipi-sdw-port-wordlength-configs", NULL, 0);
> > + if (nval > 0)
> > + dpn[i].num_words = nval;
> > +
> > + if (dpn[i].num_words) {
> > + dpn[i].words = devm_kcalloc(&slave->dev, nval,
> > + sizeof(*dpn[i].words), GFP_KERNEL);
>
> Inconsistent checks here: nval or dpn[i].num_words.

Ah yes, we should not do allocation for less that zero case and use it
properly, will fix this and others

>
> > + /* TODO: Read audio mode */
> > +
> > + i++;
> > + }
>
> Don't we use count argument for a sanity check?

Not really as that iterator runs on each bit:

for_each_set_bit(bit, &addr, 32) {

so it will not go on endlessly and can max out when all the bits being set
and stop.

--
~Vinod

\
 
 \ /
  Last update: 2017-12-11 17:56    [W:0.082 / U:4.604 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site