Re: [PATCH] Proposed module init race fix.

Roman Zippel (zippel@linux-m68k.org)
Wed, 15 Jan 2003 17:34:45 +0100


Hi,

Rusty Russell wrote:

> diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .17886-linux-2.5-bk/drivers/block/genhd.c .17886-linux-2.5-bk.updated/drivers/block/genhd.c
> --- .17886-linux-2.5-bk/drivers/block/genhd.c 2003-01-13 16:56:23.000000000 +1100
> +++ .17886-linux-2.5-bk.updated/drivers/block/genhd.c 2003-01-13 22:58:07.000000000 +1100
> @@ -104,10 +104,13 @@ static int exact_lock(dev_t dev, void *d
> * @gp: per-device partitioning information
> *
> * This function registers the partitioning information in @gp
> - * with the kernel.
> + * with the kernel. Your init function MUST NOT FAIL after this.
> */
> void add_disk(struct gendisk *disk)
> {
> + /* It needs to be accessible so we can read partitions. */
> + make_module_live(disk->fops->owner);
> +

After this the module can be removed without problems.

> disk->flags |= GENHD_FL_UP;
> blk_register_region(MKDEV(disk->major, disk->first_minor), disk->minors,
> NULL, exact_match, exact_lock, disk);

blk_register_region() allocates memory, which can fail?

bye, Roman

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/