Skip to content

Commit

Permalink
[SCSI] bsg: correct fault if queue object removed while dev_t open
Browse files Browse the repository at this point in the history
This patch corrects an issue in bsg that results in a general protection
fault if an LLD is removed while an application is using an open file
handle to a bsg device, and the application issues an ioctl. The fault
occurs because the class_dev is NULL, having been cleared in
bsg_unregister_queue() when the driver was removed.  With this
patch, a check is made for the class_dev, and the application
will receive ENXIO if the related object is gone.

Signed-off-by: Carl Lajeunesse <[email protected]>
Signed-off-by: James Smart <[email protected]>
Signed-off-by: James Bottomley <[email protected]>
  • Loading branch information
James Smart authored and James Bottomley committed Dec 9, 2010
1 parent 057f02a commit c7a841f
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions block/bsg.c
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,14 @@ bsg_map_hdr(struct bsg_device *bd, struct sg_io_v4 *hdr, fmode_t has_write_perm,
int ret, rw;
unsigned int dxfer_len;
void *dxferp = NULL;
struct bsg_class_device *bcd = &q->bsg_dev;

/* if the LLD has been removed then the bsg_unregister_queue will
* eventually be called and the class_dev was freed, so we can no
* longer use this request_queue. Return no such address.
*/
if (!bcd->class_dev)
return ERR_PTR(-ENXIO);

dprintk("map hdr %llx/%u %llx/%u\n", (unsigned long long) hdr->dout_xferp,
hdr->dout_xfer_len, (unsigned long long) hdr->din_xferp,
Expand Down

0 comments on commit c7a841f

Please sign in to comment.