[+cc Marek]
On Mon, Jun 3, 2013 at 6:44 AM, Michal Simek <michal.simek@xxxxxxxxxx> wrote:
> Check that dma_ops are initialized correctly.
>
> Signed-off-by: Michal Simek <michal.simek@xxxxxxxxxx>
> ---
> Functions dma_mmap_attrs(), dma_get_sgtable_attrs()
> already have this checking.
>
> ---
> include/asm-generic/dma-mapping-common.h | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
> diff --git a/include/asm-generic/dma-mapping-common.h b/include/asm-generic/dma-mapping-common.h
> index de8bf89..d430cab 100644
> --- a/include/asm-generic/dma-mapping-common.h
> +++ b/include/asm-generic/dma-mapping-common.h
> @@ -16,6 +16,7 @@ static inline dma_addr_t dma_map_single_attrs(struct device *dev, void *ptr,
> dma_addr_t addr;
>
> kmemcheck_mark_initialized(ptr, size);
> + BUG_ON(!ops);
Does this actually help anything? I expected that if "ops" is NULL,
we would just oops anyway when we attempted to call "ops->map_page()"
because we already trap null pointer dereferences. At least, when I
tried leaving a pci_bus.ops pointer NULL, I got a nice panic and
backtrace even without adding an explicit BUG_ON().
I cc'd Marek, who added the similar BUG_ON()s in dma_mmap_attrs() and
dma_get_sgtable_attrs() with d2b7428eb0 and 64ccc9c033.