Hi Haoxiang: Please rewrite the patch title as "soc: loongson: loongson2_guts: Add check for devm_kstrdup()", and cc soc@xxxxxxxxxx, because that is the most appropriate list for this patch. On Wed, Feb 19, 2025 at 11:23 AM Haoxiang Li <haoxiang_li2024@xxxxxxx> wrote: > > Add check for the return value of devm_kstrdup() in > loongson2_guts_probe() to catch potential exception. > > Fixes: b82621ac8450 ("soc: loongson: add GUTS driver for loongson-2 platforms") > Cc: stable@xxxxxxxxxxxxxxx > Signed-off-by: Haoxiang Li <haoxiang_li2024@xxxxxxx> > --- > drivers/soc/loongson/loongson2_guts.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/drivers/soc/loongson/loongson2_guts.c b/drivers/soc/loongson/loongson2_guts.c > index ae42e3a9127f..26212cfcf6b0 100644 > --- a/drivers/soc/loongson/loongson2_guts.c > +++ b/drivers/soc/loongson/loongson2_guts.c > @@ -117,6 +117,8 @@ static int loongson2_guts_probe(struct platform_device *pdev) > if (machine) > soc_dev_attr.machine = devm_kstrdup(dev, machine, GFP_KERNEL); > > + if (!soc_dev_attr.machine) > + return -ENOMEM; I think this exception check should follow directly after devm_kstrdup(). Otherwise the whole driver exits here when the “machine" is empty, which is not what we expect. You can refer to: https://elixir.bootlin.com/linux/v6.14-rc3/source/drivers/soc/fsl/guts.c#L224 > svr = loongson2_guts_get_svr(); > soc_die = loongson2_soc_die_match(svr, loongson2_soc_die); > if (soc_die) { > -- > 2.25.1 > > -- Thanks. Binbin