Re: [EXTERNAL] Re: [PATCH v8] ALSA: hda/tas2781: Add tas2781 hda SPI driver
From: Xu, Baojun
Date: Thu Jul 11 2024 - 05:43:18 EST
Hi Takashi,
Answer in line.
Best Regards
Jim
> From: Takashi Iwai <tiwai@xxxxxxx>
> Sent: 14 June 2024 21:20
> To: Xu, Baojun
> Cc: robh+dt@xxxxxxxxxx; andriy.shevchenko@xxxxxxxxxxxxxxx; lgirdwood@xxxxxxxxx; perex@xxxxxxxx; pierre-louis.bossart@xxxxxxxxxxxxxxx; Lu, Kevin; Ding, Shenghao; Navada Kanyana, Mukund; 13916275206@xxxxxxx; Hampiholi, Vallabha; P O, Vijeth; Holalu Yogendra, Niranjan; alsa-devel@xxxxxxxxxxxxxxxx; linux-kernel@xxxxxxxxxxxxxxx; liam.r.girdwood@xxxxxxxxx; yung-chuan.liao@xxxxxxxxxxxxxxx; broonie@xxxxxxxxxx; soyer@xxxxxx
> 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@xxxxxxxxxxx
>
> 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
>
>
>