Re: [PATCH v2 1/2] dmaengine: avalon: Intel Avalon-MM DMA Interface for PCIe
From: Greg KH
Date: Wed Oct 09 2019 - 09:07:25 EST
On Wed, Oct 09, 2019 at 12:12:30PM +0200, Alexander Gordeev wrote:
> +static int setup_dma_descs(struct dma_desc *dma_descs,
> + struct avalon_dma_desc *desc)
> +{
> + struct scatterlist *sg_stop;
> + unsigned int sg_set;
> + int ret;
> +
> + ret = setup_descs_sg(dma_descs, 0,
> + desc->direction,
> + desc->dev_addr,
> + desc->sg, desc->sg_len,
> + desc->sg_curr, desc->sg_offset,
> + &sg_stop, &sg_set);
> + BUG_ON(!ret);
Yeah, a driver can crash the kernel!
:(
Never do this, always recover properly, to not do so is "lazy"
programming.
If this is something that is impossible to ever happen, then never test
for it. But if it can happen, then properly handle the error and move
on.
Same for the other uses of BUG_ON() and WARN_ON in here. Remember many
systems run with "panic on warn" so if a user can trigger that, then the
machine reboots, which is not good.
thanks,
greg k-h