mptfusion: combine fw_event_work and its event_data
authorJoe Lawrence <joe.lawrence@stratus.com>
Wed, 25 Jun 2014 21:06:42 +0000 (17:06 -0400)
committerChristoph Hellwig <hch@lst.de>
Fri, 25 Jul 2014 21:16:58 +0000 (17:16 -0400)
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>
drivers/message/fusion/mptsas.c
drivers/message/fusion/mptsas.h

index a0d4218103db01fb045bfe38ae79734fc331256f..b0b74c4d26457805308706393fc6c4b34d2270e3 100644 (file)
@@ -990,11 +990,10 @@ mptsas_queue_device_delete(MPT_ADAPTER *ioc,
        MpiEventDataSasDeviceStatusChange_t *sas_event_data)
 {
        struct fw_event_work *fw_event;
-       int sz;
 
-       sz = offsetof(struct fw_event_work, event_data) +
-           sizeof(MpiEventDataSasDeviceStatusChange_t);
-       fw_event = kzalloc(sz, GFP_ATOMIC);
+       fw_event = kzalloc(sizeof(*fw_event) +
+                          sizeof(MpiEventDataSasDeviceStatusChange_t),
+                          GFP_ATOMIC);
        if (!fw_event) {
                printk(MYIOC_s_WARN_FMT "%s: failed at (line=%d)\n",
                    ioc->name, __func__, __LINE__);
@@ -1011,10 +1010,8 @@ static void
 mptsas_queue_rescan(MPT_ADAPTER *ioc)
 {
        struct fw_event_work *fw_event;
-       int sz;
 
-       sz = offsetof(struct fw_event_work, event_data);
-       fw_event = kzalloc(sz, GFP_ATOMIC);
+       fw_event = kzalloc(sizeof(*fw_event), GFP_ATOMIC);
        if (!fw_event) {
                printk(MYIOC_s_WARN_FMT "%s: failed at (line=%d)\n",
                    ioc->name, __func__, __LINE__);
@@ -4983,7 +4980,7 @@ static int
 mptsas_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *reply)
 {
        u32 event = le32_to_cpu(reply->Event);
-       int sz, event_data_sz;
+       int event_data_sz;
        struct fw_event_work *fw_event;
        unsigned long delay;
 
@@ -5093,8 +5090,7 @@ mptsas_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *reply)
 
        event_data_sz = ((reply->MsgLength * 4) -
            offsetof(EventNotificationReply_t, Data));
-       sz = offsetof(struct fw_event_work, event_data) + event_data_sz;
-       fw_event = kzalloc(sz, GFP_ATOMIC);
+       fw_event = kzalloc(sizeof(*fw_event) + event_data_sz, GFP_ATOMIC);
        if (!fw_event) {
                printk(MYIOC_s_WARN_FMT "%s: failed at (line=%d)\n", ioc->name,
                 __func__, __LINE__);
index 57e86ab77661361bf1dcedc9bc73ee352a54b46f..c396483d36245b6ac2683629f43eb1089614eada 100644 (file)
@@ -110,7 +110,7 @@ struct fw_event_work {
        MPT_ADAPTER     *ioc;
        u32                     event;
        u8                      retries;
-       u8                      __attribute__((aligned(4))) event_data[1];
+       char                    event_data[0] __aligned(4);
 };
 
 struct mptsas_discovery_event {
This page took 0.030199 seconds and 5 git commands to generate.