From: Dan Carpenter <dan.carpenter@linaro.org>
To: Vadim Pasternak <vadimp@nvidia.com>
Cc: platform-driver-x86@vger.kernel.org
Subject: [bug report] platform/mellanox: mlxreg-dpu: Add initial support for Nvidia DPU
Date: Fri, 2 May 2025 11:01:13 +0300 [thread overview]
Message-ID: <aBR7yX-KeZW6L3lX@stanley.mountain> (raw)
Hello Vadim Pasternak,
Commit 3e75f2954116 ("platform/mellanox: mlxreg-dpu: Add initial
support for Nvidia DPU") from Apr 21, 2025 (linux-next), leads to the
following Smatch static checker warning:
drivers/platform/mellanox/mlxreg-dpu.c:539 mlxreg_dpu_probe()
warn: refcount leak 'data->hpdev.adapter->dev.kobj.kref.refcount.refs.counter': lines='539'
drivers/platform/mellanox/mlxreg-dpu.c:565 mlxreg_dpu_probe()
warn: passing a valid pointer to 'PTR_ERR'
drivers/platform/mellanox/mlxreg-dpu.c
522 static int mlxreg_dpu_probe(struct platform_device *pdev)
523 {
524 struct mlxreg_core_data *data;
525 struct mlxreg_dpu *mlxreg_dpu;
526 void *regmap;
527 int err;
528
529 data = dev_get_platdata(&pdev->dev);
530 if (!data || !data->hpdev.brdinfo)
531 return -EINVAL;
532
533 data->hpdev.adapter = i2c_get_adapter(data->hpdev.nr);
534 if (!data->hpdev.adapter)
535 return -EPROBE_DEFER;
This should call i2c_put_adapter() before returning.
536
537 mlxreg_dpu = devm_kzalloc(&pdev->dev, sizeof(*mlxreg_dpu), GFP_KERNEL);
538 if (!mlxreg_dpu)
539 return -ENOMEM;
540
541 /* Create device at the top of DPU I2C tree. */
542 data->hpdev.client = i2c_new_client_device(data->hpdev.adapter,
543 data->hpdev.brdinfo);
544 if (IS_ERR(data->hpdev.client)) {
545 dev_err(&pdev->dev, "Failed to create client %s at bus %d at addr 0x%02x\n",
546 data->hpdev.brdinfo->type, data->hpdev.nr, data->hpdev.brdinfo->addr);
547 err = PTR_ERR(data->hpdev.client);
548 goto i2c_new_device_fail;
549 }
550
551 regmap = devm_regmap_init_i2c(data->hpdev.client, &mlxreg_dpu_regmap_conf);
552 if (IS_ERR(regmap)) {
553 dev_err(&pdev->dev, "Failed to create regmap for client %s at bus %d at addr 0x%02x\n",
554 data->hpdev.brdinfo->type, data->hpdev.nr, data->hpdev.brdinfo->addr);
555 err = PTR_ERR(regmap);
556 goto devm_regmap_init_i2c_fail;
557 }
558
559 /* Sync registers with hardware. */
560 regcache_mark_dirty(regmap);
561 err = regcache_sync(regmap);
562 if (err) {
563 dev_err(&pdev->dev, "Failed to sync regmap for client %s at bus %d at addr 0x%02x\n",
564 data->hpdev.brdinfo->type, data->hpdev.nr, data->hpdev.brdinfo->addr);
--> 565 err = PTR_ERR(regmap);
Copy and paste. "err" was already an error code. Delete this line.
566 goto regcache_sync_fail;
567 }
568
569 mlxreg_dpu->data = data;
570 mlxreg_dpu->dev = &pdev->dev;
571 platform_set_drvdata(pdev, mlxreg_dpu);
572
573 err = mlxreg_dpu_config_init(mlxreg_dpu, regmap, data, data->hpdev.brdinfo->irq);
574 if (err)
575 goto mlxreg_dpu_config_init_fail;
576
577 return err;
578
579 mlxreg_dpu_config_init_fail:
580 regcache_sync_fail:
581 devm_regmap_init_i2c_fail:
I would really encourage people to use names which reflect what
the fuction or goto does instead of where the function is called from
etc.
err_unregister:
582 i2c_unregister_device(data->hpdev.client);
583 i2c_new_device_fail:
err_i2c_put:
584 i2c_put_adapter(data->hpdev.adapter);
585 return err;
586 }
regards,
dan carpenter
reply other threads:[~2025-05-02 8:01 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aBR7yX-KeZW6L3lX@stanley.mountain \
--to=dan.carpenter@linaro.org \
--cc=platform-driver-x86@vger.kernel.org \
--cc=vadimp@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox