Re: [PATCH] CDRW packet writing support for 2.6.7-bk13

From: Christoph Hellwig
Date: Sun Jul 04 2004 - 16:08:31 EST


On Sun, Jul 04, 2004 at 01:58:42PM -0700, Andrew Morton wrote:
> Peter Osterlund <petero2@xxxxxxxxx> wrote:
> >
> > But anyway, if __bdevname() leaks a module reference it should get
> > fixed, right?
>
> Yes. The questions is, where's the bug?

in __bdevname. It shouldn't try the get_gendisk. I introduced that long
ago, but it's wrong. Use bdevname where you can, else we can't do much
else than printing the namjor/minor sanely.

The packet writing code should always use bdevname() (see my previous
mail on how to get there), and here's a patch to fix __bdevname:


--- 1.124/fs/partitions/check.c 2004-06-18 08:43:53 +02:00
+++ edited/fs/partitions/check.c 2004-07-05 01:04:11 +02:00
@@ -137,25 +137,14 @@
EXPORT_SYMBOL(bdevname);

/*
- * NOTE: this cannot be called from interrupt context.
- *
- * But in interrupt context you should really have a struct
- * block_device anyway and use bdevname() above.
+ * There's very little reason to use this, you should really
+ * have a struct block_device just about everywhere and use
+ * bdevname() instead.
*/
const char *__bdevname(dev_t dev, char *buffer)
{
- struct gendisk *disk;
- int part;
-
- disk = get_gendisk(dev, &part);
- if (disk) {
- buffer = disk_name(disk, part, buffer);
- put_disk(disk);
- } else {
- snprintf(buffer, BDEVNAME_SIZE, "unknown-block(%u,%u)",
+ snprintf(buffer, BDEVNAME_SIZE, "unknown-block(%u,%u)",
MAJOR(dev), MINOR(dev));
- }
-
return buffer;
}

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