diff options
author | Sreekanth Reddy <Sreekanth.Reddy@lsi.com> | 2013-07-25 01:54:35 -0400 |
---|---|---|
committer | James Bottomley <JBottomley@Parallels.com> | 2013-09-03 10:27:50 -0400 |
commit | 6409a7d000020ffdd61082af8bb24291d2cdc1a6 (patch) | |
tree | fa4b48400632251539614715ba356ff6e086fa70 | |
parent | 804a5cb526c121226830c686132b1b82aa12b76c (diff) |
[SCSI] mpt2sas: Null pointer deference possibility in mpt2sas_ctl_event_callback function
Added a check to identify if mpi_reply is NULL in mpt2sas_ctl_event_callback()
and return without proceeding if it is the case.
Also modified the following functions to return void instead of 0 or 1
as returning those values from events perspective doesn't make sense.
* _base_async_event()
* mpt2sas_ctl_event_callback()
* mpt2sas_scsih_event_callback()
Signed-off-by: Sreekanth Reddy <Sreekanth.Reddy@lsi.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
-rw-r--r-- | drivers/scsi/mpt2sas/mpt2sas_base.c | 11 | ||||
-rw-r--r-- | drivers/scsi/mpt2sas/mpt2sas_base.h | 4 | ||||
-rw-r--r-- | drivers/scsi/mpt2sas/mpt2sas_ctl.c | 12 | ||||
-rw-r--r-- | drivers/scsi/mpt2sas/mpt2sas_scsih.c | 21 |
4 files changed, 25 insertions, 23 deletions
diff --git a/drivers/scsi/mpt2sas/mpt2sas_base.c b/drivers/scsi/mpt2sas/mpt2sas_base.c index cf131a3de61c..a1555ca0c355 100644 --- a/drivers/scsi/mpt2sas/mpt2sas_base.c +++ b/drivers/scsi/mpt2sas/mpt2sas_base.c | |||
@@ -768,10 +768,9 @@ mpt2sas_base_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 msix_index, | |||
768 | * @msix_index: MSIX table index supplied by the OS | 768 | * @msix_index: MSIX table index supplied by the OS |
769 | * @reply: reply message frame(lower 32bit addr) | 769 | * @reply: reply message frame(lower 32bit addr) |
770 | * | 770 | * |
771 | * Return 1 meaning mf should be freed from _base_interrupt | 771 | * Returns void. |
772 | * 0 means the mf is freed from this function. | ||
773 | */ | 772 | */ |
774 | static u8 | 773 | static void |
775 | _base_async_event(struct MPT2SAS_ADAPTER *ioc, u8 msix_index, u32 reply) | 774 | _base_async_event(struct MPT2SAS_ADAPTER *ioc, u8 msix_index, u32 reply) |
776 | { | 775 | { |
777 | Mpi2EventNotificationReply_t *mpi_reply; | 776 | Mpi2EventNotificationReply_t *mpi_reply; |
@@ -780,9 +779,9 @@ _base_async_event(struct MPT2SAS_ADAPTER *ioc, u8 msix_index, u32 reply) | |||
780 | 779 | ||
781 | mpi_reply = mpt2sas_base_get_reply_virt_addr(ioc, reply); | 780 | mpi_reply = mpt2sas_base_get_reply_virt_addr(ioc, reply); |
782 | if (!mpi_reply) | 781 | if (!mpi_reply) |
783 | return 1; | 782 | return; |
784 | if (mpi_reply->Function != MPI2_FUNCTION_EVENT_NOTIFICATION) | 783 | if (mpi_reply->Function != MPI2_FUNCTION_EVENT_NOTIFICATION) |
785 | return 1; | 784 | return; |
786 | #ifdef CONFIG_SCSI_MPT2SAS_LOGGING | 785 | #ifdef CONFIG_SCSI_MPT2SAS_LOGGING |
787 | _base_display_event_data(ioc, mpi_reply); | 786 | _base_display_event_data(ioc, mpi_reply); |
788 | #endif | 787 | #endif |
@@ -812,7 +811,7 @@ _base_async_event(struct MPT2SAS_ADAPTER *ioc, u8 msix_index, u32 reply) | |||
812 | /* ctl callback handler */ | 811 | /* ctl callback handler */ |
813 | mpt2sas_ctl_event_callback(ioc, msix_index, reply); | 812 | mpt2sas_ctl_event_callback(ioc, msix_index, reply); |
814 | 813 | ||
815 | return 1; | 814 | return; |
816 | } | 815 | } |
817 | 816 | ||
818 | /** | 817 | /** |
diff --git a/drivers/scsi/mpt2sas/mpt2sas_base.h b/drivers/scsi/mpt2sas/mpt2sas_base.h index 6fbd08417773..589380ffec7f 100644 --- a/drivers/scsi/mpt2sas/mpt2sas_base.h +++ b/drivers/scsi/mpt2sas/mpt2sas_base.h | |||
@@ -1061,7 +1061,7 @@ void mpt2sas_base_update_missing_delay(struct MPT2SAS_ADAPTER *ioc, | |||
1061 | int mpt2sas_port_enable(struct MPT2SAS_ADAPTER *ioc); | 1061 | int mpt2sas_port_enable(struct MPT2SAS_ADAPTER *ioc); |
1062 | 1062 | ||
1063 | /* scsih shared API */ | 1063 | /* scsih shared API */ |
1064 | u8 mpt2sas_scsih_event_callback(struct MPT2SAS_ADAPTER *ioc, u8 msix_index, | 1064 | void mpt2sas_scsih_event_callback(struct MPT2SAS_ADAPTER *ioc, u8 msix_index, |
1065 | u32 reply); | 1065 | u32 reply); |
1066 | int mpt2sas_scsih_issue_tm(struct MPT2SAS_ADAPTER *ioc, u16 handle, | 1066 | int mpt2sas_scsih_issue_tm(struct MPT2SAS_ADAPTER *ioc, u16 handle, |
1067 | uint channel, uint id, uint lun, u8 type, u16 smid_task, | 1067 | uint channel, uint id, uint lun, u8 type, u16 smid_task, |
@@ -1144,7 +1144,7 @@ void mpt2sas_ctl_exit(void); | |||
1144 | u8 mpt2sas_ctl_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 msix_index, | 1144 | u8 mpt2sas_ctl_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 msix_index, |
1145 | u32 reply); | 1145 | u32 reply); |
1146 | void mpt2sas_ctl_reset_handler(struct MPT2SAS_ADAPTER *ioc, int reset_phase); | 1146 | void mpt2sas_ctl_reset_handler(struct MPT2SAS_ADAPTER *ioc, int reset_phase); |
1147 | u8 mpt2sas_ctl_event_callback(struct MPT2SAS_ADAPTER *ioc, u8 msix_index, | 1147 | void mpt2sas_ctl_event_callback(struct MPT2SAS_ADAPTER *ioc, u8 msix_index, |
1148 | u32 reply); | 1148 | u32 reply); |
1149 | void mpt2sas_ctl_add_to_event_log(struct MPT2SAS_ADAPTER *ioc, | 1149 | void mpt2sas_ctl_add_to_event_log(struct MPT2SAS_ADAPTER *ioc, |
1150 | Mpi2EventNotificationReply_t *mpi_reply); | 1150 | Mpi2EventNotificationReply_t *mpi_reply); |
diff --git a/drivers/scsi/mpt2sas/mpt2sas_ctl.c b/drivers/scsi/mpt2sas/mpt2sas_ctl.c index eec052c2670a..2878bd4cae30 100644 --- a/drivers/scsi/mpt2sas/mpt2sas_ctl.c +++ b/drivers/scsi/mpt2sas/mpt2sas_ctl.c | |||
@@ -397,18 +397,22 @@ mpt2sas_ctl_add_to_event_log(struct MPT2SAS_ADAPTER *ioc, | |||
397 | * This function merely adds a new work task into ioc->firmware_event_thread. | 397 | * This function merely adds a new work task into ioc->firmware_event_thread. |
398 | * The tasks are worked from _firmware_event_work in user context. | 398 | * The tasks are worked from _firmware_event_work in user context. |
399 | * | 399 | * |
400 | * Return 1 meaning mf should be freed from _base_interrupt | 400 | * Returns void. |
401 | * 0 means the mf is freed from this function. | ||
402 | */ | 401 | */ |
403 | u8 | 402 | void |
404 | mpt2sas_ctl_event_callback(struct MPT2SAS_ADAPTER *ioc, u8 msix_index, | 403 | mpt2sas_ctl_event_callback(struct MPT2SAS_ADAPTER *ioc, u8 msix_index, |
405 | u32 reply) | 404 | u32 reply) |
406 | { | 405 | { |
407 | Mpi2EventNotificationReply_t *mpi_reply; | 406 | Mpi2EventNotificationReply_t *mpi_reply; |
408 | 407 | ||
409 | mpi_reply = mpt2sas_base_get_reply_virt_addr(ioc, reply); | 408 | mpi_reply = mpt2sas_base_get_reply_virt_addr(ioc, reply); |
409 | if (unlikely(!mpi_reply)) { | ||
410 | printk(MPT2SAS_ERR_FMT "mpi_reply not valid at %s:%d/%s()!\n", | ||
411 | ioc->name, __FILE__, __LINE__, __func__); | ||
412 | return; | ||
413 | } | ||
410 | mpt2sas_ctl_add_to_event_log(ioc, mpi_reply); | 414 | mpt2sas_ctl_add_to_event_log(ioc, mpi_reply); |
411 | return 1; | 415 | return; |
412 | } | 416 | } |
413 | 417 | ||
414 | /** | 418 | /** |
diff --git a/drivers/scsi/mpt2sas/mpt2sas_scsih.c b/drivers/scsi/mpt2sas/mpt2sas_scsih.c index 389d79290861..2dbd2262f3d5 100644 --- a/drivers/scsi/mpt2sas/mpt2sas_scsih.c +++ b/drivers/scsi/mpt2sas/mpt2sas_scsih.c | |||
@@ -7471,10 +7471,9 @@ _firmware_event_work(struct work_struct *work) | |||
7471 | * This function merely adds a new work task into ioc->firmware_event_thread. | 7471 | * This function merely adds a new work task into ioc->firmware_event_thread. |
7472 | * The tasks are worked from _firmware_event_work in user context. | 7472 | * The tasks are worked from _firmware_event_work in user context. |
7473 | * | 7473 | * |
7474 | * Return 1 meaning mf should be freed from _base_interrupt | 7474 | * Returns void. |
7475 | * 0 means the mf is freed from this function. | ||
7476 | */ | 7475 | */ |
7477 | u8 | 7476 | void |
7478 | mpt2sas_scsih_event_callback(struct MPT2SAS_ADAPTER *ioc, u8 msix_index, | 7477 | mpt2sas_scsih_event_callback(struct MPT2SAS_ADAPTER *ioc, u8 msix_index, |
7479 | u32 reply) | 7478 | u32 reply) |
7480 | { | 7479 | { |
@@ -7485,14 +7484,14 @@ mpt2sas_scsih_event_callback(struct MPT2SAS_ADAPTER *ioc, u8 msix_index, | |||
7485 | 7484 | ||
7486 | /* events turned off due to host reset or driver unloading */ | 7485 | /* events turned off due to host reset or driver unloading */ |
7487 | if (ioc->remove_host || ioc->pci_error_recovery) | 7486 | if (ioc->remove_host || ioc->pci_error_recovery) |
7488 | return 1; | 7487 | return; |
7489 | 7488 | ||
7490 | mpi_reply = mpt2sas_base_get_reply_virt_addr(ioc, reply); | 7489 | mpi_reply = mpt2sas_base_get_reply_virt_addr(ioc, reply); |
7491 | 7490 | ||
7492 | if (unlikely(!mpi_reply)) { | 7491 | if (unlikely(!mpi_reply)) { |
7493 | printk(MPT2SAS_ERR_FMT "mpi_reply not valid at %s:%d/%s()!\n", | 7492 | printk(MPT2SAS_ERR_FMT "mpi_reply not valid at %s:%d/%s()!\n", |
7494 | ioc->name, __FILE__, __LINE__, __func__); | 7493 | ioc->name, __FILE__, __LINE__, __func__); |
7495 | return 1; | 7494 | return; |
7496 | } | 7495 | } |
7497 | 7496 | ||
7498 | event = le16_to_cpu(mpi_reply->Event); | 7497 | event = le16_to_cpu(mpi_reply->Event); |
@@ -7507,11 +7506,11 @@ mpt2sas_scsih_event_callback(struct MPT2SAS_ADAPTER *ioc, u8 msix_index, | |||
7507 | 7506 | ||
7508 | if (baen_data->Primitive != | 7507 | if (baen_data->Primitive != |
7509 | MPI2_EVENT_PRIMITIVE_ASYNCHRONOUS_EVENT) | 7508 | MPI2_EVENT_PRIMITIVE_ASYNCHRONOUS_EVENT) |
7510 | return 1; | 7509 | return; |
7511 | 7510 | ||
7512 | if (ioc->broadcast_aen_busy) { | 7511 | if (ioc->broadcast_aen_busy) { |
7513 | ioc->broadcast_aen_pending++; | 7512 | ioc->broadcast_aen_pending++; |
7514 | return 1; | 7513 | return; |
7515 | } else | 7514 | } else |
7516 | ioc->broadcast_aen_busy = 1; | 7515 | ioc->broadcast_aen_busy = 1; |
7517 | break; | 7516 | break; |
@@ -7587,14 +7586,14 @@ mpt2sas_scsih_event_callback(struct MPT2SAS_ADAPTER *ioc, u8 msix_index, | |||
7587 | break; | 7586 | break; |
7588 | 7587 | ||
7589 | default: /* ignore the rest */ | 7588 | default: /* ignore the rest */ |
7590 | return 1; | 7589 | return; |
7591 | } | 7590 | } |
7592 | 7591 | ||
7593 | fw_event = kzalloc(sizeof(struct fw_event_work), GFP_ATOMIC); | 7592 | fw_event = kzalloc(sizeof(struct fw_event_work), GFP_ATOMIC); |
7594 | if (!fw_event) { | 7593 | if (!fw_event) { |
7595 | printk(MPT2SAS_ERR_FMT "failure at %s:%d/%s()!\n", | 7594 | printk(MPT2SAS_ERR_FMT "failure at %s:%d/%s()!\n", |
7596 | ioc->name, __FILE__, __LINE__, __func__); | 7595 | ioc->name, __FILE__, __LINE__, __func__); |
7597 | return 1; | 7596 | return; |
7598 | } | 7597 | } |
7599 | sz = le16_to_cpu(mpi_reply->EventDataLength) * 4; | 7598 | sz = le16_to_cpu(mpi_reply->EventDataLength) * 4; |
7600 | fw_event->event_data = kzalloc(sz, GFP_ATOMIC); | 7599 | fw_event->event_data = kzalloc(sz, GFP_ATOMIC); |
@@ -7602,7 +7601,7 @@ mpt2sas_scsih_event_callback(struct MPT2SAS_ADAPTER *ioc, u8 msix_index, | |||
7602 | printk(MPT2SAS_ERR_FMT "failure at %s:%d/%s()!\n", | 7601 | printk(MPT2SAS_ERR_FMT "failure at %s:%d/%s()!\n", |
7603 | ioc->name, __FILE__, __LINE__, __func__); | 7602 | ioc->name, __FILE__, __LINE__, __func__); |
7604 | kfree(fw_event); | 7603 | kfree(fw_event); |
7605 | return 1; | 7604 | return; |
7606 | } | 7605 | } |
7607 | 7606 | ||
7608 | memcpy(fw_event->event_data, mpi_reply->EventData, | 7607 | memcpy(fw_event->event_data, mpi_reply->EventData, |
@@ -7612,7 +7611,7 @@ mpt2sas_scsih_event_callback(struct MPT2SAS_ADAPTER *ioc, u8 msix_index, | |||
7612 | fw_event->VP_ID = mpi_reply->VP_ID; | 7611 | fw_event->VP_ID = mpi_reply->VP_ID; |
7613 | fw_event->event = event; | 7612 | fw_event->event = event; |
7614 | _scsih_fw_event_add(ioc, fw_event); | 7613 | _scsih_fw_event_add(ioc, fw_event); |
7615 | return 1; | 7614 | return; |
7616 | } | 7615 | } |
7617 | 7616 | ||
7618 | /* shost template */ | 7617 | /* shost template */ |