diff --git a/drivers/spi/ltq_ssc.c b/drivers/spi/ltq_ssc.c index f2f5eaf8cd59d72556c302cf1e6de7d70433f914..f682731ef111c4288279e922718a04d14826f953 100644 --- a/drivers/spi/ltq_ssc.c +++ b/drivers/spi/ltq_ssc.c @@ -2857,6 +2857,35 @@ static INLINE int ifx_ssc_thread_init(struct ifx_ssc_port *port) } #endif /* CONFIG_LANTIQ_SPI_ASYNCHRONOUS */ +static int ifx_validate_params(IFX_SSC_HANDLE handler, char *txbuf, int txsize, + char *rxbuf, int rxsize) +{ + int status = -EINVAL; + + if (!handler) { + LOGF_KLOG_ERROR("%s: invalid handler\n", __func__); + goto out; + } + + if (!rxbuf || rxsize == 0) { + LOGF_KLOG_ERROR("%s: invalid rxbuf=%x rxsize=%d\n", + __func__, rxbuf, rxsize); + goto out; + } + + if (!txbuf || txsize == 0) { + LOGF_KLOG_ERROR("%s: invalid txbuf=%x txsize=%d\n", + __func__, txbuf, txsize); + goto out; + } + status = 0; + +out: + dump_stack(); + + return status; +} + /** * \fn int ifx_sscAsyncTxRx(IFX_SSC_HANDLE handler, * IFX_SSC_ASYNC_CALLBACK_t *pCallback, @@ -2897,13 +2926,8 @@ ifx_sscAsyncTxRx(IFX_SSC_HANDLE handler, struct ifx_ssc_port *port; struct ifx_ssc_device_stats *stats; - /*anity check */ - SSC_KASSERT((handler != NULL), - ("%s Invalid parameter\n", __func__)); - - SSC_KASSERT(!((rxbuf == NULL) && (rxsize == 0) - && (txbuf == NULL) && (txsize == 0)), - ("%s Invalid parameter\n", __func__)); + if (ifx_validate_params(handler, txbuf, txsize, rxbuf, rxsize) < 0) + return -EINVAL; dev = (ssc_device_t *) handler; stats = &dev->stats;