Re: [PATCH] Fix root hole in raw device

From: Al Viro
Date: Tue May 17 2005 - 02:50:23 EST


On Tue, May 17, 2005 at 09:07:35AM +0200, Willy Tarreau wrote:
> > struct block_device *bdev = filp->private_data;
> > int err = -EINVAL;
> >
> > - return ioctl_by_bdev(bdev, command, arg);
> > + if (bdev && bdev->bd_inode)
> > + err = blkdev_ioctl(bdev->bd_inode, filp, command, arg);
> ^^^^^^^
> Sorry, I forgot it...
> I meant the same with the NULL. Is it OK ?

What is that if () doing there? bdev->bd_inode is *never* NULL - it's
set when we allocate the bdev and never changed; the code setting it
is
if (inode->i_state & I_NEW) {
bdev->bd_contains = NULL;
bdev->bd_inode = inode;
so you are not going to have it NULL, no matter what.

And filp->private_data is set in raw_open() by
filp->private_data = bdev;
a couple of lines after
filp->f_mapping = bdev->bd_inode->i_mapping;
so it's not going to be NULL either.
-
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/