Skip to content

Commit 5345da8

Browse files
committed
Merge tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi
Pull SCSI fixes from James Bottomley: "Six fixes for mostly minor issues, most of which have small race windows for occurring" * tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi: scsi: Suppress a kernel warning in case the prep function returns BLKPREP_DEFER scsi: sg: Re-fix off by one in sg_fill_request_table() scsi: aacraid: Fix controller initialization failure scsi: hpsa: Fix configured_logical_drive_count·check scsi: qla2xxx: Initialize Work element before requesting IRQs scsi: zfcp: fix erp_action use-before-initialize in REC action trace
2 parents ea67899 + 8fe8ffb commit 5345da8

9 files changed

Lines changed: 37 additions & 22 deletions

File tree

drivers/s390/scsi/zfcp_aux.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,8 @@ struct zfcp_adapter *zfcp_adapter_enqueue(struct ccw_device *ccw_device)
357357

358358
adapter->next_port_scan = jiffies;
359359

360+
adapter->erp_action.adapter = adapter;
361+
360362
if (zfcp_qdio_setup(adapter))
361363
goto failed;
362364

@@ -513,6 +515,9 @@ struct zfcp_port *zfcp_port_enqueue(struct zfcp_adapter *adapter, u64 wwpn,
513515
port->dev.groups = zfcp_port_attr_groups;
514516
port->dev.release = zfcp_port_release;
515517

518+
port->erp_action.adapter = adapter;
519+
port->erp_action.port = port;
520+
516521
if (dev_set_name(&port->dev, "0x%016llx", (unsigned long long)wwpn)) {
517522
kfree(port);
518523
goto err_out;

drivers/s390/scsi/zfcp_erp.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,8 @@ static struct zfcp_erp_action *zfcp_erp_setup_act(int need, u32 act_status,
193193
atomic_or(ZFCP_STATUS_COMMON_ERP_INUSE,
194194
&zfcp_sdev->status);
195195
erp_action = &zfcp_sdev->erp_action;
196-
memset(erp_action, 0, sizeof(struct zfcp_erp_action));
197-
erp_action->port = port;
198-
erp_action->sdev = sdev;
196+
WARN_ON_ONCE(erp_action->port != port);
197+
WARN_ON_ONCE(erp_action->sdev != sdev);
199198
if (!(atomic_read(&zfcp_sdev->status) &
200199
ZFCP_STATUS_COMMON_RUNNING))
201200
act_status |= ZFCP_STATUS_ERP_CLOSE_ONLY;
@@ -208,8 +207,8 @@ static struct zfcp_erp_action *zfcp_erp_setup_act(int need, u32 act_status,
208207
zfcp_erp_action_dismiss_port(port);
209208
atomic_or(ZFCP_STATUS_COMMON_ERP_INUSE, &port->status);
210209
erp_action = &port->erp_action;
211-
memset(erp_action, 0, sizeof(struct zfcp_erp_action));
212-
erp_action->port = port;
210+
WARN_ON_ONCE(erp_action->port != port);
211+
WARN_ON_ONCE(erp_action->sdev != NULL);
213212
if (!(atomic_read(&port->status) & ZFCP_STATUS_COMMON_RUNNING))
214213
act_status |= ZFCP_STATUS_ERP_CLOSE_ONLY;
215214
break;
@@ -219,7 +218,8 @@ static struct zfcp_erp_action *zfcp_erp_setup_act(int need, u32 act_status,
219218
zfcp_erp_action_dismiss_adapter(adapter);
220219
atomic_or(ZFCP_STATUS_COMMON_ERP_INUSE, &adapter->status);
221220
erp_action = &adapter->erp_action;
222-
memset(erp_action, 0, sizeof(struct zfcp_erp_action));
221+
WARN_ON_ONCE(erp_action->port != NULL);
222+
WARN_ON_ONCE(erp_action->sdev != NULL);
223223
if (!(atomic_read(&adapter->status) &
224224
ZFCP_STATUS_COMMON_RUNNING))
225225
act_status |= ZFCP_STATUS_ERP_CLOSE_ONLY;
@@ -229,7 +229,11 @@ static struct zfcp_erp_action *zfcp_erp_setup_act(int need, u32 act_status,
229229
return NULL;
230230
}
231231

232-
erp_action->adapter = adapter;
232+
WARN_ON_ONCE(erp_action->adapter != adapter);
233+
memset(&erp_action->list, 0, sizeof(erp_action->list));
234+
memset(&erp_action->timer, 0, sizeof(erp_action->timer));
235+
erp_action->step = ZFCP_ERP_STEP_UNINITIALIZED;
236+
erp_action->fsf_req_id = 0;
233237
erp_action->action = need;
234238
erp_action->status = act_status;
235239

drivers/s390/scsi/zfcp_scsi.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,15 @@ static int zfcp_scsi_slave_alloc(struct scsi_device *sdev)
115115
struct zfcp_unit *unit;
116116
int npiv = adapter->connection_features & FSF_FEATURE_NPIV_MODE;
117117

118+
zfcp_sdev->erp_action.adapter = adapter;
119+
zfcp_sdev->erp_action.sdev = sdev;
120+
118121
port = zfcp_get_port_by_wwpn(adapter, rport->port_name);
119122
if (!port)
120123
return -ENXIO;
121124

125+
zfcp_sdev->erp_action.port = port;
126+
122127
unit = zfcp_unit_find(port, zfcp_scsi_dev_lun(sdev));
123128
if (unit)
124129
put_device(&unit->dev);

drivers/scsi/aacraid/comminit.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -302,9 +302,11 @@ int aac_send_shutdown(struct aac_dev * dev)
302302
return -ENOMEM;
303303
aac_fib_init(fibctx);
304304

305-
mutex_lock(&dev->ioctl_mutex);
306-
dev->adapter_shutdown = 1;
307-
mutex_unlock(&dev->ioctl_mutex);
305+
if (!dev->adapter_shutdown) {
306+
mutex_lock(&dev->ioctl_mutex);
307+
dev->adapter_shutdown = 1;
308+
mutex_unlock(&dev->ioctl_mutex);
309+
}
308310

309311
cmd = (struct aac_close *) fib_data(fibctx);
310312
cmd->command = cpu_to_le32(VM_CloseAll);

drivers/scsi/aacraid/linit.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1551,8 +1551,9 @@ static void __aac_shutdown(struct aac_dev * aac)
15511551
{
15521552
int i;
15531553

1554+
mutex_lock(&aac->ioctl_mutex);
15541555
aac->adapter_shutdown = 1;
1555-
aac_send_shutdown(aac);
1556+
mutex_unlock(&aac->ioctl_mutex);
15561557

15571558
if (aac->aif_thread) {
15581559
int i;
@@ -1565,7 +1566,11 @@ static void __aac_shutdown(struct aac_dev * aac)
15651566
}
15661567
kthread_stop(aac->thread);
15671568
}
1569+
1570+
aac_send_shutdown(aac);
1571+
15681572
aac_adapter_disable_int(aac);
1573+
15691574
if (aac_is_src(aac)) {
15701575
if (aac->max_msix > 1) {
15711576
for (i = 0; i < aac->max_msix; i++) {

drivers/scsi/hpsa.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4091,7 +4091,7 @@ static int hpsa_set_local_logical_count(struct ctlr_info *h,
40914091
memset(id_ctlr, 0, sizeof(*id_ctlr));
40924092
rc = hpsa_bmic_id_controller(h, id_ctlr, sizeof(*id_ctlr));
40934093
if (!rc)
4094-
if (id_ctlr->configured_logical_drive_count < 256)
4094+
if (id_ctlr->configured_logical_drive_count < 255)
40954095
*nlocals = id_ctlr->configured_logical_drive_count;
40964096
else
40974097
*nlocals = le16_to_cpu(

drivers/scsi/qla2xxx/qla_os.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3061,6 +3061,8 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
30613061
host->max_cmd_len, host->max_channel, host->max_lun,
30623062
host->transportt, sht->vendor_id);
30633063

3064+
INIT_WORK(&base_vha->iocb_work, qla2x00_iocb_work_fn);
3065+
30643066
/* Set up the irqs */
30653067
ret = qla2x00_request_irqs(ha, rsp);
30663068
if (ret)
@@ -3175,8 +3177,6 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
31753177
host->can_queue, base_vha->req,
31763178
base_vha->mgmt_svr_loop_id, host->sg_tablesize);
31773179

3178-
INIT_WORK(&base_vha->iocb_work, qla2x00_iocb_work_fn);
3179-
31803180
if (ha->mqenable) {
31813181
bool mq = false;
31823182
bool startit = false;

drivers/scsi/scsi_lib.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1379,8 +1379,6 @@ static int scsi_prep_fn(struct request_queue *q, struct request *req)
13791379

13801380
ret = scsi_setup_cmnd(sdev, req);
13811381
out:
1382-
if (ret != BLKPREP_OK)
1383-
cmd->flags &= ~SCMD_INITIALIZED;
13841382
return scsi_prep_return(q, req, ret);
13851383
}
13861384

@@ -1900,7 +1898,6 @@ static int scsi_mq_prep_fn(struct request *req)
19001898
struct scsi_device *sdev = req->q->queuedata;
19011899
struct Scsi_Host *shost = sdev->host;
19021900
struct scatterlist *sg;
1903-
int ret;
19041901

19051902
scsi_init_command(sdev, cmd);
19061903

@@ -1934,10 +1931,7 @@ static int scsi_mq_prep_fn(struct request *req)
19341931

19351932
blk_mq_start_request(req);
19361933

1937-
ret = scsi_setup_cmnd(sdev, req);
1938-
if (ret != BLK_STS_OK)
1939-
cmd->flags &= ~SCMD_INITIALIZED;
1940-
return ret;
1934+
return scsi_setup_cmnd(sdev, req);
19411935
}
19421936

19431937
static void scsi_mq_done(struct scsi_cmnd *cmd)

drivers/scsi/sg.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -837,7 +837,7 @@ sg_fill_request_table(Sg_fd *sfp, sg_req_info_t *rinfo)
837837

838838
val = 0;
839839
list_for_each_entry(srp, &sfp->rq_list, entry) {
840-
if (val > SG_MAX_QUEUE)
840+
if (val >= SG_MAX_QUEUE)
841841
break;
842842
rinfo[val].req_state = srp->done + 1;
843843
rinfo[val].problem =

0 commit comments

Comments
 (0)