Hi Takashi,
Answer in line.
Best Regards Jim
From: Takashi Iwai tiwai@suse.de Sent: 14 June 2024 21:20 To: Xu, Baojun Cc: robh+dt@kernel.org; andriy.shevchenko@linux.intel.com; lgirdwood@gmail.com; perex@perex.cz; pierre-louis.bossart@linux.intel.com; Lu, Kevin; Ding, Shenghao; Navada Kanyana, Mukund; 13916275206@139.com; Hampiholi, Vallabha; P O, Vijeth; Holalu Yogendra, Niranjan; alsa-devel@alsa-project.org; linux-kernel@vger.kernel.org; liam.r.girdwood@intel.com; yung-chuan.liao@linux.intel.com; broonie@kernel.org; soyer@irl.hu Subject: [EXTERNAL] Re: [PATCH v8] ALSA: hda/tas2781: Add tas2781 hda SPI driver
On Fri, 14 Jun 2024 06: 05: 54 +0200, Baojun Xu wrote: > +static struct tasdevice_config_info *tasdevice_add_config( > + struct tasdevice_priv *tas_priv, unsigned char *config_data, > + unsigned int config_size, int *status) > +{ ZjQcmQRYFpfptBannerStart This message was sent from outside of Texas Instruments. Do not click links or open attachments unless you recognize the source of this email and know the content is safe. If you wish to report this message to IT Security, please forward the message as an attachment to phishing@list.ti.com
ZjQcmQRYFpfptBannerEnd
On Fri, 14 Jun 2024 06:05:54 +0200, Baojun Xu wrote:
+static struct tasdevice_config_info *tasdevice_add_config(
struct tasdevice_priv *tas_priv, unsigned char *config_data,
unsigned int config_size, int *status)
+{
(snip)
/*
* convert data[offset], data[offset + 1], data[offset + 2] and
* data[offset + 3] into host
*/
cfg_info->nblocks = get_unaligned_be32(&config_data[config_offset]);
config_offset += 4;
/*
* Several kinds of dsp/algorithm firmwares can run on tas2781,
* the number and size of blk are not fixed and different among
* these firmwares.
*/
bk_da = cfg_info->blk_data = kcalloc(cfg_info->nblocks,
sizeof(*bk_da), GFP_KERNEL);
So the allocation size relies on the firmware data content, and it can practically any value. It'd be safer to have some sanity check for avoiding the allocation of too large pages. Ditto for other allocations in this code; you should never trust the firmware binary.
It's just size of struct tasdev_blk_data, not variable from firmware. In other kcalloc(), it's also allocate memory for structure.
Also, in general, the comments are missing for functions in tas2781_spi_fwlib.c completely. A brief comment for each function would be helpful for readers.
thanks,
Takashi