mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-05 16:54:27 +00:00
mpt3sas: combine fw_event_work and its event_data
Tack the firmware reply event_data payload to the end of its corresponding struct fw_event_work allocation. This matches the convention in the mptfusion driver and simplifies the code. This avoids the following smatch warning: drivers/scsi/mpt3sas/mpt3sas_scsih.c:2519 mpt3sas_send_trigger_data_event() warn: possible memory leak of 'fw_event' Signed-off-by: Joe Lawrence <joe.lawrence@stratus.com> Acked-by: Sreekanth Reddy <Sreekanth.Reddy@avagotech.com> Signed-off-by: Christoph Hellwig <hch@lst.de>
This commit is contained in:
parent
62c4da449d
commit
35b6236280
1 changed files with 31 additions and 25 deletions
|
@ -190,7 +190,7 @@ struct fw_event_work {
|
||||||
u8 VP_ID;
|
u8 VP_ID;
|
||||||
u8 ignore;
|
u8 ignore;
|
||||||
u16 event;
|
u16 event;
|
||||||
void *event_data;
|
char event_data[0] __aligned(4);
|
||||||
};
|
};
|
||||||
|
|
||||||
/* raid transport support */
|
/* raid transport support */
|
||||||
|
@ -2492,7 +2492,6 @@ _scsih_fw_event_free(struct MPT3SAS_ADAPTER *ioc, struct fw_event_work
|
||||||
|
|
||||||
spin_lock_irqsave(&ioc->fw_event_lock, flags);
|
spin_lock_irqsave(&ioc->fw_event_lock, flags);
|
||||||
list_del(&fw_event->list);
|
list_del(&fw_event->list);
|
||||||
kfree(fw_event->event_data);
|
|
||||||
kfree(fw_event);
|
kfree(fw_event);
|
||||||
spin_unlock_irqrestore(&ioc->fw_event_lock, flags);
|
spin_unlock_irqrestore(&ioc->fw_event_lock, flags);
|
||||||
}
|
}
|
||||||
|
@ -2513,12 +2512,10 @@ mpt3sas_send_trigger_data_event(struct MPT3SAS_ADAPTER *ioc,
|
||||||
|
|
||||||
if (ioc->is_driver_loading)
|
if (ioc->is_driver_loading)
|
||||||
return;
|
return;
|
||||||
fw_event = kzalloc(sizeof(struct fw_event_work), GFP_ATOMIC);
|
fw_event = kzalloc(sizeof(*fw_event) + sizeof(*event_data),
|
||||||
|
GFP_ATOMIC);
|
||||||
if (!fw_event)
|
if (!fw_event)
|
||||||
return;
|
return;
|
||||||
fw_event->event_data = kzalloc(sizeof(*event_data), GFP_ATOMIC);
|
|
||||||
if (!fw_event->event_data)
|
|
||||||
return;
|
|
||||||
fw_event->event = MPT3SAS_PROCESS_TRIGGER_DIAG;
|
fw_event->event = MPT3SAS_PROCESS_TRIGGER_DIAG;
|
||||||
fw_event->ioc = ioc;
|
fw_event->ioc = ioc;
|
||||||
memcpy(fw_event->event_data, event_data, sizeof(*event_data));
|
memcpy(fw_event->event_data, event_data, sizeof(*event_data));
|
||||||
|
@ -3213,7 +3210,8 @@ _scsih_check_topo_delete_events(struct MPT3SAS_ADAPTER *ioc,
|
||||||
if (fw_event->event != MPI2_EVENT_SAS_TOPOLOGY_CHANGE_LIST ||
|
if (fw_event->event != MPI2_EVENT_SAS_TOPOLOGY_CHANGE_LIST ||
|
||||||
fw_event->ignore)
|
fw_event->ignore)
|
||||||
continue;
|
continue;
|
||||||
local_event_data = fw_event->event_data;
|
local_event_data = (Mpi2EventDataSasTopologyChangeList_t *)
|
||||||
|
fw_event->event_data;
|
||||||
if (local_event_data->ExpStatus ==
|
if (local_event_data->ExpStatus ==
|
||||||
MPI2_EVENT_SAS_TOPO_ES_ADDED ||
|
MPI2_EVENT_SAS_TOPO_ES_ADDED ||
|
||||||
local_event_data->ExpStatus ==
|
local_event_data->ExpStatus ==
|
||||||
|
@ -5045,7 +5043,9 @@ _scsih_sas_topology_change_event(struct MPT3SAS_ADAPTER *ioc,
|
||||||
u64 sas_address;
|
u64 sas_address;
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
u8 link_rate, prev_link_rate;
|
u8 link_rate, prev_link_rate;
|
||||||
Mpi2EventDataSasTopologyChangeList_t *event_data = fw_event->event_data;
|
Mpi2EventDataSasTopologyChangeList_t *event_data =
|
||||||
|
(Mpi2EventDataSasTopologyChangeList_t *)
|
||||||
|
fw_event->event_data;
|
||||||
|
|
||||||
#ifdef CONFIG_SCSI_MPT3SAS_LOGGING
|
#ifdef CONFIG_SCSI_MPT3SAS_LOGGING
|
||||||
if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK)
|
if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK)
|
||||||
|
@ -5243,7 +5243,8 @@ _scsih_sas_device_status_change_event(struct MPT3SAS_ADAPTER *ioc,
|
||||||
u64 sas_address;
|
u64 sas_address;
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
Mpi2EventDataSasDeviceStatusChange_t *event_data =
|
Mpi2EventDataSasDeviceStatusChange_t *event_data =
|
||||||
fw_event->event_data;
|
(Mpi2EventDataSasDeviceStatusChange_t *)
|
||||||
|
fw_event->event_data;
|
||||||
|
|
||||||
#ifdef CONFIG_SCSI_MPT3SAS_LOGGING
|
#ifdef CONFIG_SCSI_MPT3SAS_LOGGING
|
||||||
if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK)
|
if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK)
|
||||||
|
@ -5339,6 +5340,7 @@ _scsih_sas_enclosure_dev_status_change_event(struct MPT3SAS_ADAPTER *ioc,
|
||||||
#ifdef CONFIG_SCSI_MPT3SAS_LOGGING
|
#ifdef CONFIG_SCSI_MPT3SAS_LOGGING
|
||||||
if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK)
|
if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK)
|
||||||
_scsih_sas_enclosure_dev_status_change_event_debug(ioc,
|
_scsih_sas_enclosure_dev_status_change_event_debug(ioc,
|
||||||
|
(Mpi2EventDataSasEnclDevStatusChange_t *)
|
||||||
fw_event->event_data);
|
fw_event->event_data);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -5363,7 +5365,9 @@ _scsih_sas_broadcast_primitive_event(struct MPT3SAS_ADAPTER *ioc,
|
||||||
u32 termination_count;
|
u32 termination_count;
|
||||||
u32 query_count;
|
u32 query_count;
|
||||||
Mpi2SCSITaskManagementReply_t *mpi_reply;
|
Mpi2SCSITaskManagementReply_t *mpi_reply;
|
||||||
Mpi2EventDataSasBroadcastPrimitive_t *event_data = fw_event->event_data;
|
Mpi2EventDataSasBroadcastPrimitive_t *event_data =
|
||||||
|
(Mpi2EventDataSasBroadcastPrimitive_t *)
|
||||||
|
fw_event->event_data;
|
||||||
u16 ioc_status;
|
u16 ioc_status;
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
int r;
|
int r;
|
||||||
|
@ -5515,7 +5519,8 @@ static void
|
||||||
_scsih_sas_discovery_event(struct MPT3SAS_ADAPTER *ioc,
|
_scsih_sas_discovery_event(struct MPT3SAS_ADAPTER *ioc,
|
||||||
struct fw_event_work *fw_event)
|
struct fw_event_work *fw_event)
|
||||||
{
|
{
|
||||||
Mpi2EventDataSasDiscovery_t *event_data = fw_event->event_data;
|
Mpi2EventDataSasDiscovery_t *event_data =
|
||||||
|
(Mpi2EventDataSasDiscovery_t *) fw_event->event_data;
|
||||||
|
|
||||||
#ifdef CONFIG_SCSI_MPT3SAS_LOGGING
|
#ifdef CONFIG_SCSI_MPT3SAS_LOGGING
|
||||||
if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK) {
|
if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK) {
|
||||||
|
@ -6001,7 +6006,9 @@ _scsih_sas_ir_config_change_event(struct MPT3SAS_ADAPTER *ioc,
|
||||||
Mpi2EventIrConfigElement_t *element;
|
Mpi2EventIrConfigElement_t *element;
|
||||||
int i;
|
int i;
|
||||||
u8 foreign_config;
|
u8 foreign_config;
|
||||||
Mpi2EventDataIrConfigChangeList_t *event_data = fw_event->event_data;
|
Mpi2EventDataIrConfigChangeList_t *event_data =
|
||||||
|
(Mpi2EventDataIrConfigChangeList_t *)
|
||||||
|
fw_event->event_data;
|
||||||
|
|
||||||
#ifdef CONFIG_SCSI_MPT3SAS_LOGGING
|
#ifdef CONFIG_SCSI_MPT3SAS_LOGGING
|
||||||
if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK)
|
if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK)
|
||||||
|
@ -6071,7 +6078,8 @@ _scsih_sas_ir_volume_event(struct MPT3SAS_ADAPTER *ioc,
|
||||||
u16 handle;
|
u16 handle;
|
||||||
u32 state;
|
u32 state;
|
||||||
int rc;
|
int rc;
|
||||||
Mpi2EventDataIrVolume_t *event_data = fw_event->event_data;
|
Mpi2EventDataIrVolume_t *event_data =
|
||||||
|
(Mpi2EventDataIrVolume_t *) fw_event->event_data;
|
||||||
|
|
||||||
if (ioc->shost_recovery)
|
if (ioc->shost_recovery)
|
||||||
return;
|
return;
|
||||||
|
@ -6154,7 +6162,8 @@ _scsih_sas_ir_physical_disk_event(struct MPT3SAS_ADAPTER *ioc,
|
||||||
Mpi2ConfigReply_t mpi_reply;
|
Mpi2ConfigReply_t mpi_reply;
|
||||||
Mpi2SasDevicePage0_t sas_device_pg0;
|
Mpi2SasDevicePage0_t sas_device_pg0;
|
||||||
u32 ioc_status;
|
u32 ioc_status;
|
||||||
Mpi2EventDataIrPhysicalDisk_t *event_data = fw_event->event_data;
|
Mpi2EventDataIrPhysicalDisk_t *event_data =
|
||||||
|
(Mpi2EventDataIrPhysicalDisk_t *) fw_event->event_data;
|
||||||
u64 sas_address;
|
u64 sas_address;
|
||||||
|
|
||||||
if (ioc->shost_recovery)
|
if (ioc->shost_recovery)
|
||||||
|
@ -6274,7 +6283,9 @@ static void
|
||||||
_scsih_sas_ir_operation_status_event(struct MPT3SAS_ADAPTER *ioc,
|
_scsih_sas_ir_operation_status_event(struct MPT3SAS_ADAPTER *ioc,
|
||||||
struct fw_event_work *fw_event)
|
struct fw_event_work *fw_event)
|
||||||
{
|
{
|
||||||
Mpi2EventDataIrOperationStatus_t *event_data = fw_event->event_data;
|
Mpi2EventDataIrOperationStatus_t *event_data =
|
||||||
|
(Mpi2EventDataIrOperationStatus_t *)
|
||||||
|
fw_event->event_data;
|
||||||
static struct _raid_device *raid_device;
|
static struct _raid_device *raid_device;
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
u16 handle;
|
u16 handle;
|
||||||
|
@ -7036,7 +7047,9 @@ _mpt3sas_fw_work(struct MPT3SAS_ADAPTER *ioc, struct fw_event_work *fw_event)
|
||||||
|
|
||||||
switch (fw_event->event) {
|
switch (fw_event->event) {
|
||||||
case MPT3SAS_PROCESS_TRIGGER_DIAG:
|
case MPT3SAS_PROCESS_TRIGGER_DIAG:
|
||||||
mpt3sas_process_trigger_data(ioc, fw_event->event_data);
|
mpt3sas_process_trigger_data(ioc,
|
||||||
|
(struct SL_WH_TRIGGERS_EVENT_DATA_T *)
|
||||||
|
fw_event->event_data);
|
||||||
break;
|
break;
|
||||||
case MPT3SAS_REMOVE_UNRESPONDING_DEVICES:
|
case MPT3SAS_REMOVE_UNRESPONDING_DEVICES:
|
||||||
while (scsi_host_in_recovery(ioc->shost) || ioc->shost_recovery)
|
while (scsi_host_in_recovery(ioc->shost) || ioc->shost_recovery)
|
||||||
|
@ -7194,20 +7207,13 @@ mpt3sas_scsih_event_callback(struct MPT3SAS_ADAPTER *ioc, u8 msix_index,
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
fw_event = kzalloc(sizeof(struct fw_event_work), GFP_ATOMIC);
|
sz = le16_to_cpu(mpi_reply->EventDataLength) * 4;
|
||||||
|
fw_event = kzalloc(sizeof(*fw_event) + sz, GFP_ATOMIC);
|
||||||
if (!fw_event) {
|
if (!fw_event) {
|
||||||
pr_err(MPT3SAS_FMT "failure at %s:%d/%s()!\n",
|
pr_err(MPT3SAS_FMT "failure at %s:%d/%s()!\n",
|
||||||
ioc->name, __FILE__, __LINE__, __func__);
|
ioc->name, __FILE__, __LINE__, __func__);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
sz = le16_to_cpu(mpi_reply->EventDataLength) * 4;
|
|
||||||
fw_event->event_data = kzalloc(sz, GFP_ATOMIC);
|
|
||||||
if (!fw_event->event_data) {
|
|
||||||
pr_err(MPT3SAS_FMT "failure at %s:%d/%s()!\n",
|
|
||||||
ioc->name, __FILE__, __LINE__, __func__);
|
|
||||||
kfree(fw_event);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
memcpy(fw_event->event_data, mpi_reply->EventData, sz);
|
memcpy(fw_event->event_data, mpi_reply->EventData, sz);
|
||||||
fw_event->ioc = ioc;
|
fw_event->ioc = ioc;
|
||||||
|
|
Loading…
Add table
Reference in a new issue