Commit f888ba3c authored by James.Smart@Emulex.Com's avatar James.Smart@Emulex.Com Committed by James Bottomley

[SCSI] lpfc driver 8.0.30 : fix get_stats panic

Fix panic in lpfc_get_stats()

Symptoms: Panic on sysfs stats access

Cause: In lpfc_get_stats() we are writing to memory that we do not
own.

Fix: Fix our stats structure allocation. Embed phba->link_stats in
struct lpfc_hba and stop treating it like rogue structure.

Note: Embedding midlayer/transport structure in our structure caused
need for more files to include midlayer/transport headers.
Signed-off-by: default avatarJames Smart <James.Smart@emulex.com>
Signed-off-by: default avatarJames Bottomley <James.Bottomley@SteelEye.com>
parent 69859dc4
...@@ -342,9 +342,6 @@ struct lpfc_hba { ...@@ -342,9 +342,6 @@ struct lpfc_hba {
#define VPD_MASK 0xf /* mask for any vpd data */ #define VPD_MASK 0xf /* mask for any vpd data */
struct timer_list els_tmofunc; struct timer_list els_tmofunc;
void *link_stats;
/* /*
* stat counters * stat counters
*/ */
...@@ -370,6 +367,8 @@ struct lpfc_hba { ...@@ -370,6 +367,8 @@ struct lpfc_hba {
struct list_head freebufList; struct list_head freebufList;
struct list_head ctrspbuflist; struct list_head ctrspbuflist;
struct list_head rnidrspbuflist; struct list_head rnidrspbuflist;
struct fc_host_statistics link_stats;
}; };
......
...@@ -988,8 +988,7 @@ lpfc_get_stats(struct Scsi_Host *shost) ...@@ -988,8 +988,7 @@ lpfc_get_stats(struct Scsi_Host *shost)
{ {
struct lpfc_hba *phba = (struct lpfc_hba *)shost->hostdata[0]; struct lpfc_hba *phba = (struct lpfc_hba *)shost->hostdata[0];
struct lpfc_sli *psli = &phba->sli; struct lpfc_sli *psli = &phba->sli;
struct fc_host_statistics *hs = struct fc_host_statistics *hs = &phba->link_stats;
(struct fc_host_statistics *)phba->link_stats;
LPFC_MBOXQ_t *pmboxq; LPFC_MBOXQ_t *pmboxq;
MAILBOX_t *pmb; MAILBOX_t *pmb;
int rc=0; int rc=0;
...@@ -1020,6 +1019,8 @@ lpfc_get_stats(struct Scsi_Host *shost) ...@@ -1020,6 +1019,8 @@ lpfc_get_stats(struct Scsi_Host *shost)
return NULL; return NULL;
} }
memset(hs, 0, sizeof (struct fc_host_statistics));
hs->tx_frames = pmb->un.varRdStatus.xmitFrameCnt; hs->tx_frames = pmb->un.varRdStatus.xmitFrameCnt;
hs->tx_words = (pmb->un.varRdStatus.xmitByteCnt * 256); hs->tx_words = (pmb->un.varRdStatus.xmitByteCnt * 256);
hs->rx_frames = pmb->un.varRdStatus.rcvFrameCnt; hs->rx_frames = pmb->un.varRdStatus.rcvFrameCnt;
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include <scsi/scsi_device.h> #include <scsi/scsi_device.h>
#include <scsi/scsi_host.h> #include <scsi/scsi_host.h>
#include <scsi/scsi_transport_fc.h>
#include "lpfc_hw.h" #include "lpfc_hw.h"
#include "lpfc_sli.h" #include "lpfc_sli.h"
......
...@@ -1339,14 +1339,12 @@ lpfc_pci_probe_one(struct pci_dev *pdev, const struct pci_device_id *pid) ...@@ -1339,14 +1339,12 @@ lpfc_pci_probe_one(struct pci_dev *pdev, const struct pci_device_id *pid)
if (pci_request_regions(pdev, LPFC_DRIVER_NAME)) if (pci_request_regions(pdev, LPFC_DRIVER_NAME))
goto out_disable_device; goto out_disable_device;
host = scsi_host_alloc(&lpfc_template, host = scsi_host_alloc(&lpfc_template, sizeof (struct lpfc_hba));
sizeof (struct lpfc_hba) + sizeof (unsigned long));
if (!host) if (!host)
goto out_release_regions; goto out_release_regions;
phba = (struct lpfc_hba*)host->hostdata; phba = (struct lpfc_hba*)host->hostdata;
memset(phba, 0, sizeof (struct lpfc_hba)); memset(phba, 0, sizeof (struct lpfc_hba));
phba->link_stats = (void *)&phba[1];
phba->host = host; phba->host = host;
phba->fc_flag |= FC_LOADING; phba->fc_flag |= FC_LOADING;
......
...@@ -23,6 +23,9 @@ ...@@ -23,6 +23,9 @@
#include <linux/pci.h> #include <linux/pci.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <scsi/scsi_device.h>
#include <scsi/scsi_transport_fc.h>
#include "lpfc_hw.h" #include "lpfc_hw.h"
#include "lpfc_sli.h" #include "lpfc_sli.h"
#include "lpfc_disc.h" #include "lpfc_disc.h"
......
...@@ -23,6 +23,9 @@ ...@@ -23,6 +23,9 @@
#include <linux/pci.h> #include <linux/pci.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <scsi/scsi_device.h>
#include <scsi/scsi_transport_fc.h>
#include "lpfc_hw.h" #include "lpfc_hw.h"
#include "lpfc_sli.h" #include "lpfc_sli.h"
#include "lpfc_disc.h" #include "lpfc_disc.h"
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include <scsi/scsi_cmnd.h> #include <scsi/scsi_cmnd.h>
#include <scsi/scsi_device.h> #include <scsi/scsi_device.h>
#include <scsi/scsi_host.h> #include <scsi/scsi_host.h>
#include <scsi/scsi_transport_fc.h>
#include "lpfc_hw.h" #include "lpfc_hw.h"
#include "lpfc_sli.h" #include "lpfc_sli.h"
......
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