Re: [PATCH 2/2] ASoC: spacemit: init *dp to NULL before error paths
"Troy Mitchell" <[email protected]> Sun, 02 Aug 2026 19:29:42 -0700
| Newsgroups | dev.linux.lists.spacemit,org.infradead.lists.linux-riscv,org.kernel.vger.linux-kernel,org.kernel.vger.linux-sound |
|---|---|
| Message-ID | <[email protected]> |
--b221c2993898b54412cec0db06be210fff76d164353ddb68c3a0007334fe
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=UTF-8
> The current caller does check the return value before using dp, so this
> isn't an active bug. Still, initialize *dp to NULL upfront as a defensive
> measure, consistent with how core helpers like _snd_pcm_new() handle
> their optional output parameters.
If devm_kmemdup() fails, spacemit_i2s_init_dai() returns -ENOMEM. The
sole caller checks the return value and returns immediately, so it never
accesses dai on that path. On success, dp is non-NULL and *dp is assigned
before the function returns.
Therefore, I do not see a path where initializing *dp to NULL has any
effect. Could you clarify what case this change is intended to handle?
- Troy
--b221c2993898b54412cec0db06be210fff76d164353ddb68c3a0007334fe
Content-Type: application/pgp-signature; name="signature.asc"
-----BEGIN PGP SIGNATURE-----
iIMEABYKACsWIQSL4Ay2cExaPXAQcU2YCe+A+TM0LwUCam/9Fg0caUB0cm95LXku
b3JnAAoJEJgJ74D5MzQvFGcA/R3CHaTVtH2RGXHY16xO3fRcol8fUVuIUUe+TR1t
9JgJAP91jUDciFgUl5vhTEeiVakcOt9V0hoWOqKp3sSSP0aYCw==
=VXsS
-----END PGP SIGNATURE-----
--b221c2993898b54412cec0db06be210fff76d164353ddb68c3a0007334fe--