soundwire: stream: fix NULL pointer dereference for multi_link
[platform/kernel/linux-starfive.git] / drivers / soundwire / stream.c
index d77a8a0..68d5488 100644 (file)
@@ -742,14 +742,15 @@ error_1:
  * sdw_ml_sync_bank_switch: Multilink register bank switch
  *
  * @bus: SDW bus instance
+ * @multi_link: whether this is a multi-link stream with hardware-based sync
  *
  * Caller function should free the buffers on error
  */
-static int sdw_ml_sync_bank_switch(struct sdw_bus *bus)
+static int sdw_ml_sync_bank_switch(struct sdw_bus *bus, bool multi_link)
 {
        unsigned long time_left;
 
-       if (!bus->multi_link)
+       if (!multi_link)
                return 0;
 
        /* Wait for completion of transfer */
@@ -847,7 +848,7 @@ static int do_bank_switch(struct sdw_stream_runtime *stream)
                        bus->bank_switch_timeout = DEFAULT_BANK_SWITCH_TIMEOUT;
 
                /* Check if bank switch was successful */
-               ret = sdw_ml_sync_bank_switch(bus);
+               ret = sdw_ml_sync_bank_switch(bus, multi_link);
                if (ret < 0) {
                        dev_err(bus->dev,
                                "multi link bank switch failed: %d\n", ret);