public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Németh Márton" <nm127@freemail.hu>
To: LKML <linux-kernel@vger.kernel.org>
Subject: pair of alloc_disk()?
Date: Wed, 07 Jan 2009 07:00:25 +0100	[thread overview]
Message-ID: <496444F9.2020202@freemail.hu> (raw)

Hi,

I cannot find free_disk() or similar function which takes "struct gendisk"
as a parameter and can do the reverse thing what alloc_disk() do.

Could you please give me a hint what would be the correct function call
in the following example in test_exit_module() so the module do not leak?


#include <linux/module.h>
#include <linux/genhd.h>

MODULE_AUTHOR("Márton Németh <nm127@freemail.hu>");
MODULE_DESCRIPTION("Test alloc_disk");
MODULE_LICENSE("GPL");

static struct gendisk *gd_ptr;

static int test_init_module(void)
{
        printk(KERN_DEBUG "starting module\n");

        gd_ptr = alloc_disk(1);
        if (!gd_ptr) {
                return -ENOMEM;
        }

        printk(KERN_DEBUG "gd_ptr after alloc=%p\n", gd_ptr);

        return 0;
}


static void test_exit_module(void)
{
        printk(KERN_DEBUG "unloading module\n");

        /* FIXME: no free_disk(gd_ptr) is available */
}

module_init(test_init_module);
module_exit(test_exit_module);

Regards,

	Márton Németh

             reply	other threads:[~2009-01-07  6:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-07  6:00 Németh Márton [this message]
2009-01-08  5:56 ` pair of alloc_disk()? + OOPS Németh Márton
2009-01-08  6:27   ` Németh Márton

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=496444F9.2020202@freemail.hu \
    --to=nm127@freemail.hu \
    --cc=linux-kernel@vger.kernel.org \
    /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