Commit 16070428 authored by Jens Axboe's avatar Jens Axboe Committed by Linus Torvalds

[PATCH] fix cdrom open

Some time ago the cdrom open routine was changed so that we call the
driver's open routine before checking to see if it is read only.  However,
if we discovered that a read write open was not possible and the open
flags required a writable open, we just returned -EROFS without calling
the driver's release routine.   This seems to work for most cdrom drivers,
but breaks the Powerpc iSeries virtual cdrom rather badly.

This just inserts the release call in the error path to balance the call
to "->open()" done by "open_for_data()".
Signed-off-by: default avatarStephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: default avatarJens Axboe <axboe@suse.de>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 553698f9
...@@ -1009,9 +1009,9 @@ int cdrom_open(struct cdrom_device_info *cdi, struct inode *ip, struct file *fp) ...@@ -1009,9 +1009,9 @@ int cdrom_open(struct cdrom_device_info *cdi, struct inode *ip, struct file *fp)
if (fp->f_mode & FMODE_WRITE) { if (fp->f_mode & FMODE_WRITE) {
ret = -EROFS; ret = -EROFS;
if (cdrom_open_write(cdi)) if (cdrom_open_write(cdi))
goto err; goto err_release;
if (!CDROM_CAN(CDC_RAM)) if (!CDROM_CAN(CDC_RAM))
goto err; goto err_release;
ret = 0; ret = 0;
cdi->media_written = 0; cdi->media_written = 0;
} }
...@@ -1026,6 +1026,8 @@ int cdrom_open(struct cdrom_device_info *cdi, struct inode *ip, struct file *fp) ...@@ -1026,6 +1026,8 @@ int cdrom_open(struct cdrom_device_info *cdi, struct inode *ip, struct file *fp)
not be mounting, but opening with O_NONBLOCK */ not be mounting, but opening with O_NONBLOCK */
check_disk_change(ip->i_bdev); check_disk_change(ip->i_bdev);
return 0; return 0;
err_release:
cdi->ops->release(cdi);
err: err:
cdi->use_count--; cdi->use_count--;
return ret; return ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment