Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Joe Lawrence and committed by
Christoph Hellwig
32696198 c9834c70

+7 -11
+6 -10
drivers/message/fusion/mptsas.c
··· 990 990 MpiEventDataSasDeviceStatusChange_t *sas_event_data) 991 991 { 992 992 struct fw_event_work *fw_event; 993 - int sz; 994 993 995 - sz = offsetof(struct fw_event_work, event_data) + 996 - sizeof(MpiEventDataSasDeviceStatusChange_t); 997 - fw_event = kzalloc(sz, GFP_ATOMIC); 994 + fw_event = kzalloc(sizeof(*fw_event) + 995 + sizeof(MpiEventDataSasDeviceStatusChange_t), 996 + GFP_ATOMIC); 998 997 if (!fw_event) { 999 998 printk(MYIOC_s_WARN_FMT "%s: failed at (line=%d)\n", 1000 999 ioc->name, __func__, __LINE__); ··· 1010 1011 mptsas_queue_rescan(MPT_ADAPTER *ioc) 1011 1012 { 1012 1013 struct fw_event_work *fw_event; 1013 - int sz; 1014 1014 1015 - sz = offsetof(struct fw_event_work, event_data); 1016 - fw_event = kzalloc(sz, GFP_ATOMIC); 1015 + fw_event = kzalloc(sizeof(*fw_event), GFP_ATOMIC); 1017 1016 if (!fw_event) { 1018 1017 printk(MYIOC_s_WARN_FMT "%s: failed at (line=%d)\n", 1019 1018 ioc->name, __func__, __LINE__); ··· 4980 4983 mptsas_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *reply) 4981 4984 { 4982 4985 u32 event = le32_to_cpu(reply->Event); 4983 - int sz, event_data_sz; 4986 + int event_data_sz; 4984 4987 struct fw_event_work *fw_event; 4985 4988 unsigned long delay; 4986 4989 ··· 5090 5093 5091 5094 event_data_sz = ((reply->MsgLength * 4) - 5092 5095 offsetof(EventNotificationReply_t, Data)); 5093 - sz = offsetof(struct fw_event_work, event_data) + event_data_sz; 5094 - fw_event = kzalloc(sz, GFP_ATOMIC); 5096 + fw_event = kzalloc(sizeof(*fw_event) + event_data_sz, GFP_ATOMIC); 5095 5097 if (!fw_event) { 5096 5098 printk(MYIOC_s_WARN_FMT "%s: failed at (line=%d)\n", ioc->name, 5097 5099 __func__, __LINE__);
+1 -1
drivers/message/fusion/mptsas.h
··· 110 110 MPT_ADAPTER *ioc; 111 111 u32 event; 112 112 u8 retries; 113 - u8 __attribute__((aligned(4))) event_data[1]; 113 + char event_data[0] __aligned(4); 114 114 }; 115 115 116 116 struct mptsas_discovery_event {