Linux-HyperV List
 help / color / mirror / Atom feed
From: Dan Carpenter <error27@gmail.com>
To: Long Li <longli@microsoft.com>
Cc: linux-hyperv@vger.kernel.org
Subject: [bug report] net: mana: Add support for auxiliary device
Date: Wed, 15 Jul 2026 08:52:00 +0300	[thread overview]
Message-ID: <alcgAA38gD9FJJd4@stanley.mountain> (raw)

Hello Long Li,

Commit a69839d4327d ("net: mana: Add support for auxiliary device")
from Nov 3, 2022 (linux-next), leads to the following Smatch static
checker warning:

	drivers/net/ethernet/microsoft/mana/mana_en.c:3893 add_adev()
	warn: 'madev' was already freed. (line 3868)

drivers/net/ethernet/microsoft/mana/mana_en.c
    3848 static int add_adev(struct gdma_dev *gd, const char *name)
    3849 {
    3850         struct auxiliary_device *adev;
    3851         struct mana_adev *madev;
    3852         int ret;
    3853         int id;
    3854 
    3855         madev = kzalloc_obj(*madev);
    3856         if (!madev)
    3857                 return -ENOMEM;
    3858 
    3859         adev = &madev->adev;
    3860         ret = mana_adev_idx_alloc();
    3861         if (ret < 0)
    3862                 goto idx_fail;
    3863         id = ret;
    3864         adev->id = id;
    3865 
    3866         adev->name = name;
    3867         adev->dev.parent = gd->gdma_context->dev;
    3868         adev->dev.release = adev_release;

The adev_release() is assigned here.

    3869         madev->mdev = gd;
    3870 
    3871         ret = auxiliary_device_init(adev);
    3872         if (ret)
    3873                 goto init_fail;
    3874 
    3875         /* madev is owned by the auxiliary device */
    3876         madev = NULL;
    3877         ret = auxiliary_device_add(adev);
    3878         if (ret)
    3879                 goto add_fail;

This goto...

    3880 
    3881         gd->adev = adev;
    3882         dev_dbg(gd->gdma_context->dev,
    3883                 "Auxiliary device added successfully\n");
    3884         return 0;
    3885 
    3886 add_fail:
    3887         auxiliary_device_uninit(adev);

Free adev.

    3888 
    3889 init_fail:
    3890         mana_adev_idx_free(id);
    3891 
    3892 idx_fail:
--> 3893         kfree(madev);

Double free.

    3894 
    3895         return ret;
    3896 }

This email is a free service from the Smatch-CI project [smatch.sf.net].

regards,
dan carpenter

                 reply	other threads:[~2026-07-15  5:52 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=alcgAA38gD9FJJd4@stanley.mountain \
    --to=error27@gmail.com \
    --cc=linux-hyperv@vger.kernel.org \
    --cc=longli@microsoft.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