Skip to content

Commit 7622976

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: "Ten patches, eight in drivers and two in the core, which correct a regression from directory removal and add a no VPD size quirk also to fix a regression. All pretty small" * tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi: scsi: ufs: mcq: Use active_reqs to check busy in clock scaling scsi: core: Fix a procfs host directory removal regression scsi: core: Add BLIST_NO_VPD_SIZE for some VDASD scsi: mpi3mr: Fix expander node leak in mpi3mr_remove() scsi: mpi3mr: Fix memory leaks in mpi3mr_init_ioc() scsi: mpi3mr: Fix sas_hba.phy memory leak in mpi3mr_remove() scsi: mpi3mr: Fix mpi3mr_hba_port memory leak in mpi3mr_remove() scsi: mpi3mr: Fix config page DMA memory leak scsi: mpi3mr: Fix throttle_groups memory leak scsi: mpt3sas: Fix NULL pointer access in mpt3sas_transport_port_add()
2 parents 38e04b3 + c600102 commit 7622976

File tree

12 files changed

+85
-34
lines changed

12 files changed

+85
-34
lines changed

drivers/scsi/hosts.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -341,9 +341,6 @@ static void scsi_host_dev_release(struct device *dev)
341341
struct Scsi_Host *shost = dev_to_shost(dev);
342342
struct device *parent = dev->parent;
343343

344-
/* In case scsi_remove_host() has not been called. */
345-
scsi_proc_hostdir_rm(shost->hostt);
346-
347344
/* Wait for functions invoked through call_rcu(&scmd->rcu, ...) */
348345
rcu_barrier();
349346

drivers/scsi/mpi3mr/mpi3mr.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1393,4 +1393,6 @@ void mpi3mr_flush_drv_cmds(struct mpi3mr_ioc *mrioc);
13931393
void mpi3mr_flush_cmds_for_unrecovered_controller(struct mpi3mr_ioc *mrioc);
13941394
void mpi3mr_free_enclosure_list(struct mpi3mr_ioc *mrioc);
13951395
int mpi3mr_process_admin_reply_q(struct mpi3mr_ioc *mrioc);
1396+
void mpi3mr_expander_node_remove(struct mpi3mr_ioc *mrioc,
1397+
struct mpi3mr_sas_node *sas_expander);
13961398
#endif /*MPI3MR_H_INCLUDED*/

drivers/scsi/mpi3mr/mpi3mr_fw.c

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3837,29 +3837,34 @@ int mpi3mr_init_ioc(struct mpi3mr_ioc *mrioc)
38373837

38383838
mpi3mr_print_ioc_info(mrioc);
38393839

3840-
dprint_init(mrioc, "allocating config page buffers\n");
3841-
mrioc->cfg_page = dma_alloc_coherent(&mrioc->pdev->dev,
3842-
MPI3MR_DEFAULT_CFG_PAGE_SZ, &mrioc->cfg_page_dma, GFP_KERNEL);
38433840
if (!mrioc->cfg_page) {
3844-
retval = -1;
3845-
goto out_failed_noretry;
3841+
dprint_init(mrioc, "allocating config page buffers\n");
3842+
mrioc->cfg_page_sz = MPI3MR_DEFAULT_CFG_PAGE_SZ;
3843+
mrioc->cfg_page = dma_alloc_coherent(&mrioc->pdev->dev,
3844+
mrioc->cfg_page_sz, &mrioc->cfg_page_dma, GFP_KERNEL);
3845+
if (!mrioc->cfg_page) {
3846+
retval = -1;
3847+
goto out_failed_noretry;
3848+
}
38463849
}
38473850

3848-
mrioc->cfg_page_sz = MPI3MR_DEFAULT_CFG_PAGE_SZ;
3849-
3850-
retval = mpi3mr_alloc_reply_sense_bufs(mrioc);
3851-
if (retval) {
3852-
ioc_err(mrioc,
3853-
"%s :Failed to allocated reply sense buffers %d\n",
3854-
__func__, retval);
3855-
goto out_failed_noretry;
3851+
if (!mrioc->init_cmds.reply) {
3852+
retval = mpi3mr_alloc_reply_sense_bufs(mrioc);
3853+
if (retval) {
3854+
ioc_err(mrioc,
3855+
"%s :Failed to allocated reply sense buffers %d\n",
3856+
__func__, retval);
3857+
goto out_failed_noretry;
3858+
}
38563859
}
38573860

3858-
retval = mpi3mr_alloc_chain_bufs(mrioc);
3859-
if (retval) {
3860-
ioc_err(mrioc, "Failed to allocated chain buffers %d\n",
3861-
retval);
3862-
goto out_failed_noretry;
3861+
if (!mrioc->chain_sgl_list) {
3862+
retval = mpi3mr_alloc_chain_bufs(mrioc);
3863+
if (retval) {
3864+
ioc_err(mrioc, "Failed to allocated chain buffers %d\n",
3865+
retval);
3866+
goto out_failed_noretry;
3867+
}
38633868
}
38643869

38653870
retval = mpi3mr_issue_iocinit(mrioc);
@@ -4382,13 +4387,20 @@ void mpi3mr_free_mem(struct mpi3mr_ioc *mrioc)
43824387
mrioc->admin_req_base, mrioc->admin_req_dma);
43834388
mrioc->admin_req_base = NULL;
43844389
}
4385-
4390+
if (mrioc->cfg_page) {
4391+
dma_free_coherent(&mrioc->pdev->dev, mrioc->cfg_page_sz,
4392+
mrioc->cfg_page, mrioc->cfg_page_dma);
4393+
mrioc->cfg_page = NULL;
4394+
}
43864395
if (mrioc->pel_seqnum_virt) {
43874396
dma_free_coherent(&mrioc->pdev->dev, mrioc->pel_seqnum_sz,
43884397
mrioc->pel_seqnum_virt, mrioc->pel_seqnum_dma);
43894398
mrioc->pel_seqnum_virt = NULL;
43904399
}
43914400

4401+
kfree(mrioc->throttle_groups);
4402+
mrioc->throttle_groups = NULL;
4403+
43924404
kfree(mrioc->logdata_buf);
43934405
mrioc->logdata_buf = NULL;
43944406

drivers/scsi/mpi3mr/mpi3mr_os.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5078,6 +5078,8 @@ static void mpi3mr_remove(struct pci_dev *pdev)
50785078
struct workqueue_struct *wq;
50795079
unsigned long flags;
50805080
struct mpi3mr_tgt_dev *tgtdev, *tgtdev_next;
5081+
struct mpi3mr_hba_port *port, *hba_port_next;
5082+
struct mpi3mr_sas_node *sas_expander, *sas_expander_next;
50815083

50825084
if (!shost)
50835085
return;
@@ -5117,6 +5119,28 @@ static void mpi3mr_remove(struct pci_dev *pdev)
51175119
mpi3mr_free_mem(mrioc);
51185120
mpi3mr_cleanup_resources(mrioc);
51195121

5122+
spin_lock_irqsave(&mrioc->sas_node_lock, flags);
5123+
list_for_each_entry_safe_reverse(sas_expander, sas_expander_next,
5124+
&mrioc->sas_expander_list, list) {
5125+
spin_unlock_irqrestore(&mrioc->sas_node_lock, flags);
5126+
mpi3mr_expander_node_remove(mrioc, sas_expander);
5127+
spin_lock_irqsave(&mrioc->sas_node_lock, flags);
5128+
}
5129+
list_for_each_entry_safe(port, hba_port_next, &mrioc->hba_port_table_list, list) {
5130+
ioc_info(mrioc,
5131+
"removing hba_port entry: %p port: %d from hba_port list\n",
5132+
port, port->port_id);
5133+
list_del(&port->list);
5134+
kfree(port);
5135+
}
5136+
spin_unlock_irqrestore(&mrioc->sas_node_lock, flags);
5137+
5138+
if (mrioc->sas_hba.num_phys) {
5139+
kfree(mrioc->sas_hba.phy);
5140+
mrioc->sas_hba.phy = NULL;
5141+
mrioc->sas_hba.num_phys = 0;
5142+
}
5143+
51205144
spin_lock(&mrioc_list_lock);
51215145
list_del(&mrioc->list);
51225146
spin_unlock(&mrioc_list_lock);

drivers/scsi/mpi3mr/mpi3mr_transport.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@
99

1010
#include "mpi3mr.h"
1111

12-
static void mpi3mr_expander_node_remove(struct mpi3mr_ioc *mrioc,
13-
struct mpi3mr_sas_node *sas_expander);
14-
1512
/**
1613
* mpi3mr_post_transport_req - Issue transport requests and wait
1714
* @mrioc: Adapter instance reference
@@ -2164,7 +2161,7 @@ int mpi3mr_expander_add(struct mpi3mr_ioc *mrioc, u16 handle)
21642161
*
21652162
* Return nothing.
21662163
*/
2167-
static void mpi3mr_expander_node_remove(struct mpi3mr_ioc *mrioc,
2164+
void mpi3mr_expander_node_remove(struct mpi3mr_ioc *mrioc,
21682165
struct mpi3mr_sas_node *sas_expander)
21692166
{
21702167
struct mpi3mr_sas_port *mr_sas_port, *next;

drivers/scsi/mpt3sas/mpt3sas_transport.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -785,7 +785,7 @@ mpt3sas_transport_port_add(struct MPT3SAS_ADAPTER *ioc, u16 handle,
785785
goto out_fail;
786786
}
787787
port = sas_port_alloc_num(sas_node->parent_dev);
788-
if ((sas_port_add(port))) {
788+
if (!port || (sas_port_add(port))) {
789789
ioc_err(ioc, "failure at %s:%d/%s()!\n",
790790
__FILE__, __LINE__, __func__);
791791
goto out_fail;
@@ -824,13 +824,20 @@ mpt3sas_transport_port_add(struct MPT3SAS_ADAPTER *ioc, u16 handle,
824824
mpt3sas_port->remote_identify.sas_address;
825825
}
826826

827+
if (!rphy) {
828+
ioc_err(ioc, "failure at %s:%d/%s()!\n",
829+
__FILE__, __LINE__, __func__);
830+
goto out_delete_port;
831+
}
832+
827833
rphy->identify = mpt3sas_port->remote_identify;
828834

829835
if ((sas_rphy_add(rphy))) {
830836
ioc_err(ioc, "failure at %s:%d/%s()!\n",
831837
__FILE__, __LINE__, __func__);
832838
sas_rphy_free(rphy);
833839
rphy = NULL;
840+
goto out_delete_port;
834841
}
835842

836843
if (mpt3sas_port->remote_identify.device_type == SAS_END_DEVICE) {
@@ -857,7 +864,10 @@ mpt3sas_transport_port_add(struct MPT3SAS_ADAPTER *ioc, u16 handle,
857864
rphy_to_expander_device(rphy), hba_port->port_id);
858865
return mpt3sas_port;
859866

860-
out_fail:
867+
out_delete_port:
868+
sas_port_delete(port);
869+
870+
out_fail:
861871
list_for_each_entry_safe(mpt3sas_phy, next, &mpt3sas_port->phy_list,
862872
port_siblings)
863873
list_del(&mpt3sas_phy->port_siblings);

drivers/scsi/scsi.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,9 @@ static int scsi_get_vpd_size(struct scsi_device *sdev, u8 page)
326326
unsigned char vpd_header[SCSI_VPD_HEADER_SIZE] __aligned(4);
327327
int result;
328328

329+
if (sdev->no_vpd_size)
330+
return SCSI_DEFAULT_VPD_LEN;
331+
329332
/*
330333
* Fetch the VPD page header to find out how big the page
331334
* is. This is done to prevent problems on legacy devices

drivers/scsi/scsi_devinfo.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ static struct {
134134
{"3PARdata", "VV", NULL, BLIST_REPORTLUN2},
135135
{"ADAPTEC", "AACRAID", NULL, BLIST_FORCELUN},
136136
{"ADAPTEC", "Adaptec 5400S", NULL, BLIST_FORCELUN},
137-
{"AIX", "VDASD", NULL, BLIST_TRY_VPD_PAGES},
137+
{"AIX", "VDASD", NULL, BLIST_TRY_VPD_PAGES | BLIST_NO_VPD_SIZE},
138138
{"AFT PRO", "-IX CF", "0.0>", BLIST_FORCELUN},
139139
{"BELKIN", "USB 2 HS-CF", "1.95", BLIST_FORCELUN | BLIST_INQUIRY_36},
140140
{"BROWNIE", "1200U3P", NULL, BLIST_NOREPORTLUN},
@@ -188,6 +188,7 @@ static struct {
188188
{"HPE", "OPEN-", "*", BLIST_REPORTLUN2 | BLIST_TRY_VPD_PAGES},
189189
{"IBM", "AuSaV1S2", NULL, BLIST_FORCELUN},
190190
{"IBM", "ProFibre 4000R", "*", BLIST_SPARSELUN | BLIST_LARGELUN},
191+
{"IBM", "2076", NULL, BLIST_NO_VPD_SIZE},
191192
{"IBM", "2105", NULL, BLIST_RETRY_HWERROR},
192193
{"iomega", "jaz 1GB", "J.86", BLIST_NOTQ | BLIST_NOLUN},
193194
{"IOMEGA", "ZIP", NULL, BLIST_NOTQ | BLIST_NOLUN},

drivers/scsi/scsi_scan.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1057,6 +1057,9 @@ static int scsi_add_lun(struct scsi_device *sdev, unsigned char *inq_result,
10571057
else if (*bflags & BLIST_SKIP_VPD_PAGES)
10581058
sdev->skip_vpd_pages = 1;
10591059

1060+
if (*bflags & BLIST_NO_VPD_SIZE)
1061+
sdev->no_vpd_size = 1;
1062+
10601063
transport_configure_device(&sdev->sdev_gendev);
10611064

10621065
if (sdev->host->hostt->slave_configure) {

drivers/ufs/core/ufshcd.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1500,7 +1500,7 @@ static int ufshcd_devfreq_get_dev_status(struct device *dev,
15001500
scaling->window_start_t = curr_t;
15011501
scaling->tot_busy_t = 0;
15021502

1503-
if (hba->outstanding_reqs) {
1503+
if (scaling->active_reqs) {
15041504
scaling->busy_start_t = curr_t;
15051505
scaling->is_busy_started = true;
15061506
} else {
@@ -2118,7 +2118,7 @@ static void ufshcd_clk_scaling_update_busy(struct ufs_hba *hba)
21182118

21192119
spin_lock_irqsave(hba->host->host_lock, flags);
21202120
hba->clk_scaling.active_reqs--;
2121-
if (!hba->outstanding_reqs && scaling->is_busy_started) {
2121+
if (!scaling->active_reqs && scaling->is_busy_started) {
21222122
scaling->tot_busy_t += ktime_to_us(ktime_sub(ktime_get(),
21232123
scaling->busy_start_t));
21242124
scaling->busy_start_t = 0;

0 commit comments

Comments
 (0)