Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753004AbdLKQ4m (ORCPT ); Mon, 11 Dec 2017 11:56:42 -0500 Received: from mga14.intel.com ([192.55.52.115]:39765 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752941AbdLKQ4k (ORCPT ); Mon, 11 Dec 2017 11:56:40 -0500 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,392,1508828400"; d="scan'208";a="183280109" Date: Mon, 11 Dec 2017 22:30:22 +0530 From: Vinod Koul To: Takashi Iwai Cc: Greg Kroah-Hartman , LKML , ALSA , Mark , Pierre , patches.audio@intel.com, alan@linux.intel.com, Charles Keepax , Sagar Dharia , srinivas.kandagatla@linaro.org, plai@codeaurora.org, Sudheer Papothi Subject: Re: [PATCH v5 04/15] soundwire: Add MIPI DisCo property helpers Message-ID: <20171211170022.GT18649@localhost> References: <1512575231-4154-1-git-send-email-vinod.koul@intel.com> <1512575231-4154-5-git-send-email-vinod.koul@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1026 Lines: 39 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