From 88d9be07a6a87b8cb158e8de6138f030bf85ae95 Mon Sep 17 00:00:00 2001
From: Jeffrey Lee <jlee@gitlab.riscosopen.org>
Date: Tue, 23 Feb 2016 20:44:03 +0000
Subject: [PATCH] Fix null pointer dereference

Detail:
  s/Module - Fix null pointer dereference in drive detection code if an ATAPI drive is found which failed to respond to ADFS's identify packet
Admin:
  Tested in Iyonix ROM softload
  Should fix issue reported on forums:
  https://www.riscosopen.org/forum/forums/5/topics/3929


Version 1.34, 1.11.2.1. Tagged as 'ATAPI-1_34-1_11_2_1'
---
 VersionASM | 10 +++++-----
 VersionNum | 14 +++++++-------
 s/Module   |  6 ++++++
 3 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/VersionASM b/VersionASM
index 51c428b..19069c9 100644
--- a/VersionASM
+++ b/VersionASM
@@ -13,11 +13,11 @@
                         GBLS    Module_ComponentPath
 Module_MajorVersion     SETS    "1.34"
 Module_Version          SETA    134
-Module_MinorVersion     SETS    ""
-Module_Date             SETS    "17 Jul 2015"
-Module_ApplicationDate  SETS    "17-Jul-15"
+Module_MinorVersion     SETS    "1.11.2.1"
+Module_Date             SETS    "23 Feb 2016"
+Module_ApplicationDate  SETS    "23-Feb-16"
 Module_ComponentName    SETS    "ATAPI"
 Module_ComponentPath    SETS    "castle/RiscOS/Sources/HWSupport/CD/ATAPI"
-Module_FullVersion      SETS    "1.34"
-Module_HelpVersion      SETS    "1.34 (17 Jul 2015)"
+Module_FullVersion      SETS    "1.34 (1.11.2.1)"
+Module_HelpVersion      SETS    "1.34 (23 Feb 2016) 1.11.2.1"
                         END
diff --git a/VersionNum b/VersionNum
index b7a406f..0e7e78d 100644
--- a/VersionNum
+++ b/VersionNum
@@ -5,19 +5,19 @@
  *
  */
 #define Module_MajorVersion_CMHG        1.34
-#define Module_MinorVersion_CMHG        
-#define Module_Date_CMHG                17 Jul 2015
+#define Module_MinorVersion_CMHG        1.11.2.1
+#define Module_Date_CMHG                23 Feb 2016
 
 #define Module_MajorVersion             "1.34"
 #define Module_Version                  134
-#define Module_MinorVersion             ""
-#define Module_Date                     "17 Jul 2015"
+#define Module_MinorVersion             "1.11.2.1"
+#define Module_Date                     "23 Feb 2016"
 
-#define Module_ApplicationDate          "17-Jul-15"
+#define Module_ApplicationDate          "23-Feb-16"
 
 #define Module_ComponentName            "ATAPI"
 #define Module_ComponentPath            "castle/RiscOS/Sources/HWSupport/CD/ATAPI"
 
-#define Module_FullVersion              "1.34"
-#define Module_HelpVersion              "1.34 (17 Jul 2015)"
+#define Module_FullVersion              "1.34 (1.11.2.1)"
+#define Module_HelpVersion              "1.34 (23 Feb 2016) 1.11.2.1"
 #define Module_LibraryVersionInfo       "1:34"
diff --git a/s/Module b/s/Module
index fb57937..0eff847 100644
--- a/s/Module
+++ b/s/Module
@@ -269,6 +269,12 @@ MIC_IdentifyLoop
  STRNEB     r8, [r5, r4]
  BNE        MIC_DoneCheckForATAPI
 
+; Although it's been detected as ATAPI, there'd no guarantee that it will have responded to the identify packet
+
+        CMP     r3, #0
+        STREQB  r8, [r5, r4]
+        BEQ     MIC_DoneCheckForATAPI
+
         LDRB    r9, [r3, #ATAPIID__GENERAL_CONFIGURATION + 1]
         LDRB    r14,[r3, #ATAPIID__GENERAL_CONFIGURATION]
         ORR     r9,r14,r9,LSL # 8
-- 
GitLab