diff options
author | Joe Lawrence <joe.lawrence@stratus.com> | 2014-06-25 17:06:42 -0400 |
---|---|---|
committer | Christoph Hellwig <hch@lst.de> | 2014-07-25 17:16:58 -0400 |
commit | 32696198745a74b37bc27498a5ade169d2c04c5e (patch) | |
tree | 6b86964c219585ccd11131dc3523b78eff309299 /drivers/message/fusion | |
parent | c9834c70efbaaa1461ec04289d97a842244fb294 (diff) |
mptfusion: 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. Rework fw_event_work
allocation calculations to include the event_data size where
appropriate.
This clarifies the code a bit and avoids the following smatch warnings:
drivers/message/fusion/mptsas.c:1003 mptsas_queue_device_delete()
error: memcpy() 'fw_event->event_data' too small (29 vs 36)
drivers/message/fusion/mptsas.c:1017 mptsas_queue_rescan() error: not
allocating enough data 168 vs 160
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>
Diffstat (limited to 'drivers/message/fusion')
-rw-r--r-- | drivers/message/fusion/mptsas.c | 16 | ||||
-rw-r--r-- | drivers/message/fusion/mptsas.h | 2 |
2 files changed, 7 insertions, 11 deletions
diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c index a0d4218103db..b0b74c4d2645 100644 --- a/drivers/message/fusion/mptsas.c +++ b/drivers/message/fusion/mptsas.c | |||
@@ -990,11 +990,10 @@ mptsas_queue_device_delete(MPT_ADAPTER *ioc, | |||
990 | MpiEventDataSasDeviceStatusChange_t *sas_event_data) | 990 | MpiEventDataSasDeviceStatusChange_t *sas_event_data) |
991 | { | 991 | { |
992 | struct fw_event_work *fw_event; | 992 | struct fw_event_work *fw_event; |
993 | int sz; | ||
994 | 993 | ||
995 | sz = offsetof(struct fw_event_work, event_data) + | 994 | fw_event = kzalloc(sizeof(*fw_event) + |
996 | sizeof(MpiEventDataSasDeviceStatusChange_t); | 995 | sizeof(MpiEventDataSasDeviceStatusChange_t), |
997 | fw_event = kzalloc(sz, GFP_ATOMIC); | 996 | GFP_ATOMIC); |
998 | if (!fw_event) { | 997 | if (!fw_event) { |
999 | printk(MYIOC_s_WARN_FMT "%s: failed at (line=%d)\n", | 998 | printk(MYIOC_s_WARN_FMT "%s: failed at (line=%d)\n", |
1000 | ioc->name, __func__, __LINE__); | 999 | ioc->name, __func__, __LINE__); |
@@ -1011,10 +1010,8 @@ static void | |||
1011 | mptsas_queue_rescan(MPT_ADAPTER *ioc) | 1010 | mptsas_queue_rescan(MPT_ADAPTER *ioc) |
1012 | { | 1011 | { |
1013 | struct fw_event_work *fw_event; | 1012 | struct fw_event_work *fw_event; |
1014 | int sz; | ||
1015 | 1013 | ||
1016 | sz = offsetof(struct fw_event_work, event_data); | 1014 | fw_event = kzalloc(sizeof(*fw_event), GFP_ATOMIC); |
1017 | fw_event = kzalloc(sz, GFP_ATOMIC); | ||
1018 | if (!fw_event) { | 1015 | if (!fw_event) { |
1019 | printk(MYIOC_s_WARN_FMT "%s: failed at (line=%d)\n", | 1016 | printk(MYIOC_s_WARN_FMT "%s: failed at (line=%d)\n", |
1020 | ioc->name, __func__, __LINE__); | 1017 | ioc->name, __func__, __LINE__); |
@@ -4983,7 +4980,7 @@ static int | |||
4983 | mptsas_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *reply) | 4980 | mptsas_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *reply) |
4984 | { | 4981 | { |
4985 | u32 event = le32_to_cpu(reply->Event); | 4982 | u32 event = le32_to_cpu(reply->Event); |
4986 | int sz, event_data_sz; | 4983 | int event_data_sz; |
4987 | struct fw_event_work *fw_event; | 4984 | struct fw_event_work *fw_event; |
4988 | unsigned long delay; | 4985 | unsigned long delay; |
4989 | 4986 | ||
@@ -5093,8 +5090,7 @@ mptsas_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *reply) | |||
5093 | 5090 | ||
5094 | event_data_sz = ((reply->MsgLength * 4) - | 5091 | event_data_sz = ((reply->MsgLength * 4) - |
5095 | offsetof(EventNotificationReply_t, Data)); | 5092 | offsetof(EventNotificationReply_t, Data)); |
5096 | sz = offsetof(struct fw_event_work, event_data) + event_data_sz; | 5093 | fw_event = kzalloc(sizeof(*fw_event) + event_data_sz, GFP_ATOMIC); |
5097 | fw_event = kzalloc(sz, GFP_ATOMIC); | ||
5098 | if (!fw_event) { | 5094 | if (!fw_event) { |
5099 | printk(MYIOC_s_WARN_FMT "%s: failed at (line=%d)\n", ioc->name, | 5095 | printk(MYIOC_s_WARN_FMT "%s: failed at (line=%d)\n", ioc->name, |
5100 | __func__, __LINE__); | 5096 | __func__, __LINE__); |
diff --git a/drivers/message/fusion/mptsas.h b/drivers/message/fusion/mptsas.h index 57e86ab77661..c396483d3624 100644 --- a/drivers/message/fusion/mptsas.h +++ b/drivers/message/fusion/mptsas.h | |||
@@ -110,7 +110,7 @@ struct fw_event_work { | |||
110 | MPT_ADAPTER *ioc; | 110 | MPT_ADAPTER *ioc; |
111 | u32 event; | 111 | u32 event; |
112 | u8 retries; | 112 | u8 retries; |
113 | u8 __attribute__((aligned(4))) event_data[1]; | 113 | char event_data[0] __aligned(4); |
114 | }; | 114 | }; |
115 | 115 | ||
116 | struct mptsas_discovery_event { | 116 | struct mptsas_discovery_event { |