fixed null pointer dereference with loading module on system with no unipi board
authorMiroslav Ondra <ondra@faster.cz>
Wed, 31 Oct 2018 01:41:41 +0000 (02:41 +0100)
committerMiroslav Ondra <ondra@faster.cz>
Wed, 31 Oct 2018 01:41:41 +0000 (02:41 +0100)
debian/changelog
debian/neuron-kernel.changelog
modules/unipi/src/unipi_common.h
modules/unipi/src/unipi_spi.c

index 158be87ad0f0ee856288894770da1b6fd9b3b63e..5c73809789d31144277ecfa5284d3b2c7d9e22c6 100644 (file)
@@ -1,5 +1,6 @@
 unipi-kernel-modules (1.18) unstable; urgency=medium
 
+  * disabled long spi tranfer
   * added missing dummy method for reading secondary analog output
 
  -- Miroslav Ondra <bokula@bokula.faster.cz>  Mon, 16 Oct 2018 15:08:40 +0200
index 18d22226993ddea41d08bc379c221b5c813a983c..29df870634c3473c18738f52d2a3915ba3633fd1 100644 (file)
@@ -1,3 +1,16 @@
+unipi-kernel-modules (1.18.1.20180924-1) unstable; urgency=medium
+
+  * Compiled for raspberrypi-kernel 1.20180924-1
+
+ -- Miroslav Ondra <bokula@bokula.faster.cz>  Fri, 19 Oct 2018 10:09:57 +0200
+
+unipi-kernel-modules (1.18) unstable; urgency=medium
+
+  * disabled long spi tranfer
+  * added missing dummy method for reading secondary analog output
+
+ -- Miroslav Ondra <bokula@bokula.faster.cz>  Mon, 16 Oct 2018 15:08:40 +0200
+
 unipi-kernel-modules (1.17.1.20180924-1) unstable; urgency=medium
 
   * Compiled for raspberrypi-kernel 1.20180924-1
index 6f5fc4a8bc045c7172b2cefdacaeb715ad970c3d..7628fb82548a7101a83e55c3273d967efe62c861 100644 (file)
@@ -51,7 +51,7 @@
 #if NEURONSPI_SCHED_REQUIRED > 0
        #include <uapi/linux/sched/types.h>
 #endif
-#define NEURONSPI_MAJOR_VERSIONSTRING "Version 1.18:2018:10:16"
+#define NEURONSPI_MAJOR_VERSIONSTRING "Version 1.18:2018:10:31"
 
 #define NEURONSPI_MAX_DEVS                             3
 #define NEURONSPI_MAX_UART                             16
@@ -64,7 +64,7 @@
 #define NEURONSPI_DEFAULT_FREQ                 600000
 #define NEURONSPI_COMMON_FREQ                  12000000
 #define NEURONSPI_SLOWER_FREQ                  7500000
-#define NEURONSPI_MAX_TX                               62
+#define NEURONSPI_MAX_TX                               60
 //#define NEURONSPI_MAX_TX                             256
 #define NEURONSPI_MAX_BAUD                             115200
 #define NEURONSPI_FIFO_SIZE                            256
index 54abaa711e17129d5a2258ab5694ba0a1d33db86..3aacf9b14902b570ba901f213c4291bae128d646 100644 (file)
@@ -570,7 +570,7 @@ void neuronspi_spi_uart_read(struct spi_device* spi, u8 *recv_buf, s32 len, u8 u
        send_op.first_message[2] = 0;
        send_op.first_message[3] = uart_index;
 
-       send_buf = kzalloc(transmit_len, GFP_ATOMIC);
+       send_buf = kzalloc(transmit_len+64/*safety space*/, GFP_ATOMIC);
 
 #if 1
        send_op.first_message[0] = 0x65;
@@ -1053,7 +1053,7 @@ struct file_operations file_ops =
 int char_register_driver(void)
 {
     int major;
-    
+    struct device *parent = NULL;
        if (neuronspi_cdrv.major_number >= 0) return 0;
 
        // Character device registration
@@ -1078,8 +1078,9 @@ int char_register_driver(void)
        // Device driver registration
        /*neuronspi_cdrv.dev = device_create_with_groups(neuronspi_cdrv.driver_class, &(neuron_plc_dev->dev), \
                             MKDEV(major, 0), NULL, neuron_plc_attr_groups, NEURON_DEVICE_NAME);*/
-            
-       neuronspi_cdrv.dev = device_create(neuronspi_cdrv.driver_class, &(neuron_plc_dev->dev), MKDEV(major, 0), \
+
+    if (neuron_plc_dev != NULL) parent = &(neuron_plc_dev->dev);
+       neuronspi_cdrv.dev = device_create(neuronspi_cdrv.driver_class, parent, MKDEV(major, 0), \
                             neuron_plc_dev, NEURON_DEVICE_NAME);
        if (IS_ERR(neuronspi_cdrv.dev)) {
                class_destroy(neuronspi_cdrv.driver_class);