scsi: megaraid_sas: Check valid aen class range to avoid kernel panic
authorShivasharan S <shivasharan.srikanteshwara@broadcom.com>
Wed, 23 Aug 2017 11:47:01 +0000 (04:47 -0700)
committerMartin K. Petersen <martin.petersen@oracle.com>
Fri, 25 Aug 2017 02:29:13 +0000 (22:29 -0400)
Signed-off-by: Kashyap Desai <kashyap.desai@broadcom.com>
Signed-off-by: Shivasharan S <shivasharan.srikanteshwara@broadcom.com>
Cc: stable@vger.kernel.org
Reviewed-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Tomas Henzl <thenzl@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/megaraid/megaraid_sas_base.c

index b8b46540d90915826a6cda73996e30551479889a..df2332f3e18225fce5067d43ee321ec8998d9eab 100644 (file)
@@ -5651,6 +5651,14 @@ megasas_register_aen(struct megasas_instance *instance, u32 seq_num,
                prev_aen.word =
                        le32_to_cpu(instance->aen_cmd->frame->dcmd.mbox.w[1]);
 
+               if ((curr_aen.members.class < MFI_EVT_CLASS_DEBUG) ||
+                   (curr_aen.members.class > MFI_EVT_CLASS_DEAD)) {
+                       dev_info(&instance->pdev->dev,
+                                "%s %d out of range class %d send by application\n",
+                                __func__, __LINE__, curr_aen.members.class);
+                       return 0;
+               }
+
                /*
                 * A class whose enum value is smaller is inclusive of all
                 * higher values. If a PROGRESS (= -1) was previously