Skip to content

Commit 77c51ba

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: "Five small fixes, all in drivers. Most of these are error leg freeing issues, with the only really user visible one being the zfcp fix" * tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi: scsi: iscsi: Fix possible memory leak when device_register() failed scsi: zfcp: Fix double free of FSF request when qdio send fails scsi: scsi_debug: Fix possible UAF in sdebug_add_host_helper() scsi: target: tcm_loop: Fix possible name leak in tcm_loop_setup_hba_bus() scsi: mpi3mr: Suppress command reply debug prints
2 parents b6e7fdf + f014165 commit 77c51ba

File tree

5 files changed

+26
-19
lines changed

5 files changed

+26
-19
lines changed

drivers/s390/scsi/zfcp_fsf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -884,7 +884,7 @@ static int zfcp_fsf_req_send(struct zfcp_fsf_req *req)
884884
const bool is_srb = zfcp_fsf_req_is_status_read_buffer(req);
885885
struct zfcp_adapter *adapter = req->adapter;
886886
struct zfcp_qdio *qdio = adapter->qdio;
887-
int req_id = req->req_id;
887+
unsigned long req_id = req->req_id;
888888

889889
zfcp_reqlist_add(adapter->req_list, req);
890890

drivers/scsi/mpi3mr/mpi3mr_os.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3265,7 +3265,8 @@ void mpi3mr_process_op_reply_desc(struct mpi3mr_ioc *mrioc,
32653265
}
32663266

32673267
if (scmd->result != (DID_OK << 16) && (scmd->cmnd[0] != ATA_12) &&
3268-
(scmd->cmnd[0] != ATA_16)) {
3268+
(scmd->cmnd[0] != ATA_16) &&
3269+
mrioc->logging_level & MPI3_DEBUG_SCSI_ERROR) {
32693270
ioc_info(mrioc, "%s :scmd->result 0x%x\n", __func__,
32703271
scmd->result);
32713272
scsi_print_command(scmd);

drivers/scsi/scsi_debug.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7323,8 +7323,12 @@ static int sdebug_add_host_helper(int per_host_idx)
73237323
dev_set_name(&sdbg_host->dev, "adapter%d", sdebug_num_hosts);
73247324

73257325
error = device_register(&sdbg_host->dev);
7326-
if (error)
7326+
if (error) {
7327+
spin_lock(&sdebug_host_list_lock);
7328+
list_del(&sdbg_host->host_list);
7329+
spin_unlock(&sdebug_host_list_lock);
73277330
goto clean;
7331+
}
73287332

73297333
++sdebug_num_hosts;
73307334
return 0;

drivers/scsi/scsi_transport_iscsi.c

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ iscsi_create_endpoint(int dd_size)
231231
dev_set_name(&ep->dev, "ep-%d", id);
232232
err = device_register(&ep->dev);
233233
if (err)
234-
goto free_id;
234+
goto put_dev;
235235

236236
err = sysfs_create_group(&ep->dev.kobj, &iscsi_endpoint_group);
237237
if (err)
@@ -245,10 +245,12 @@ iscsi_create_endpoint(int dd_size)
245245
device_unregister(&ep->dev);
246246
return NULL;
247247

248-
free_id:
248+
put_dev:
249249
mutex_lock(&iscsi_ep_idr_mutex);
250250
idr_remove(&iscsi_ep_idr, id);
251251
mutex_unlock(&iscsi_ep_idr_mutex);
252+
put_device(&ep->dev);
253+
return NULL;
252254
free_ep:
253255
kfree(ep);
254256
return NULL;
@@ -766,7 +768,7 @@ iscsi_create_iface(struct Scsi_Host *shost, struct iscsi_transport *transport,
766768

767769
err = device_register(&iface->dev);
768770
if (err)
769-
goto free_iface;
771+
goto put_dev;
770772

771773
err = sysfs_create_group(&iface->dev.kobj, &iscsi_iface_group);
772774
if (err)
@@ -780,9 +782,8 @@ iscsi_create_iface(struct Scsi_Host *shost, struct iscsi_transport *transport,
780782
device_unregister(&iface->dev);
781783
return NULL;
782784

783-
free_iface:
784-
put_device(iface->dev.parent);
785-
kfree(iface);
785+
put_dev:
786+
put_device(&iface->dev);
786787
return NULL;
787788
}
788789
EXPORT_SYMBOL_GPL(iscsi_create_iface);
@@ -1251,15 +1252,15 @@ iscsi_create_flashnode_sess(struct Scsi_Host *shost, int index,
12511252

12521253
err = device_register(&fnode_sess->dev);
12531254
if (err)
1254-
goto free_fnode_sess;
1255+
goto put_dev;
12551256

12561257
if (dd_size)
12571258
fnode_sess->dd_data = &fnode_sess[1];
12581259

12591260
return fnode_sess;
12601261

1261-
free_fnode_sess:
1262-
kfree(fnode_sess);
1262+
put_dev:
1263+
put_device(&fnode_sess->dev);
12631264
return NULL;
12641265
}
12651266
EXPORT_SYMBOL_GPL(iscsi_create_flashnode_sess);
@@ -1299,15 +1300,15 @@ iscsi_create_flashnode_conn(struct Scsi_Host *shost,
12991300

13001301
err = device_register(&fnode_conn->dev);
13011302
if (err)
1302-
goto free_fnode_conn;
1303+
goto put_dev;
13031304

13041305
if (dd_size)
13051306
fnode_conn->dd_data = &fnode_conn[1];
13061307

13071308
return fnode_conn;
13081309

1309-
free_fnode_conn:
1310-
kfree(fnode_conn);
1310+
put_dev:
1311+
put_device(&fnode_conn->dev);
13111312
return NULL;
13121313
}
13131314
EXPORT_SYMBOL_GPL(iscsi_create_flashnode_conn);
@@ -4815,7 +4816,7 @@ iscsi_register_transport(struct iscsi_transport *tt)
48154816
dev_set_name(&priv->dev, "%s", tt->name);
48164817
err = device_register(&priv->dev);
48174818
if (err)
4818-
goto free_priv;
4819+
goto put_dev;
48194820

48204821
err = sysfs_create_group(&priv->dev.kobj, &iscsi_transport_group);
48214822
if (err)
@@ -4850,8 +4851,8 @@ iscsi_register_transport(struct iscsi_transport *tt)
48504851
unregister_dev:
48514852
device_unregister(&priv->dev);
48524853
return NULL;
4853-
free_priv:
4854-
kfree(priv);
4854+
put_dev:
4855+
put_device(&priv->dev);
48554856
return NULL;
48564857
}
48574858
EXPORT_SYMBOL_GPL(iscsi_register_transport);

drivers/target/loopback/tcm_loop.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,7 @@ static int tcm_loop_setup_hba_bus(struct tcm_loop_hba *tl_hba, int tcm_loop_host
397397
ret = device_register(&tl_hba->dev);
398398
if (ret) {
399399
pr_err("device_register() failed for tl_hba->dev: %d\n", ret);
400+
put_device(&tl_hba->dev);
400401
return -ENODEV;
401402
}
402403

@@ -1073,7 +1074,7 @@ static struct se_wwn *tcm_loop_make_scsi_hba(
10731074
*/
10741075
ret = tcm_loop_setup_hba_bus(tl_hba, tcm_loop_hba_no_cnt);
10751076
if (ret)
1076-
goto out;
1077+
return ERR_PTR(ret);
10771078

10781079
sh = tl_hba->sh;
10791080
tcm_loop_hba_no_cnt++;

0 commit comments

Comments
 (0)