[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20191009130720.GA4148375@kroah.com>
Date: Wed, 9 Oct 2019 15:07:20 +0200
From: Greg KH <gregkh@...uxfoundation.org>
To: Alexander Gordeev <a.gordeev.box@...il.com>
Cc: linux-kernel@...r.kernel.org, devel@...verdev.osuosl.org,
Michael Chen <micchen@...era.com>, dmaengine@...r.kernel.org
Subject: Re: [PATCH v2 1/2] dmaengine: avalon: Intel Avalon-MM DMA Interface
for PCIe
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
Powered by blists - more mailing lists