Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ec9c96ef authored by Kyle McMartin's avatar Kyle McMartin Committed by Ingo Molnar
Browse files

dma-debug: Fix check_unmap null pointer dereference



While it's debatable whether or not a NULL device argument to
the DMA API functions is valid... since it certainly isn't
valid on devices with an IOMMU... dma-debug really shouldn't be
dereferencing null pointers either.

Guard against that in err_printk and the driver_filter
functions. A Fedora rawhide user was seeing this in one of the
dvb drivers resulting in an oops on boot.

[ A patch has been sent for testing to the driver, but I feel
  the dma debugging support should be fixed as well. (There's
  still a pile of legacy garbage in the kernel passing null
  pointers to dma_{alloc,free}_*. :( ]

Signed-off-by: default avatarKyle McMartin <kyle@redhat.com>
Cc: mchehab@infradead.org
Cc: Joerg Roedel <joerg.roedel@amd.com>
LKML-Reference: <20090820011708.GP25206@bombadil.infradead.org>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent 429966b8
Loading
Loading
Loading
Loading
+16 −12
Original line number Original line Diff line number Diff line
@@ -156,9 +156,13 @@ static bool driver_filter(struct device *dev)
		return true;
		return true;


	/* driver filter on and initialized */
	/* driver filter on and initialized */
	if (current_driver && dev->driver == current_driver)
	if (current_driver && dev && dev->driver == current_driver)
		return true;
		return true;


	/* driver filter on, but we can't filter on a NULL device... */
	if (!dev)
		return false;

	if (current_driver || !current_driver_name[0])
	if (current_driver || !current_driver_name[0])
		return false;
		return false;


@@ -188,8 +192,8 @@ static bool driver_filter(struct device *dev)
		if (driver_filter(dev) &&				\
		if (driver_filter(dev) &&				\
		    (show_all_errors || show_num_errors > 0)) {		\
		    (show_all_errors || show_num_errors > 0)) {		\
			WARN(1, "%s %s: " format,			\
			WARN(1, "%s %s: " format,			\
			     dev_driver_string(dev),		\
			     dev ? dev_driver_string(dev) : "NULL",	\
			     dev_name(dev) , ## arg);		\
			     dev ? dev_name(dev) : "NULL", ## arg);	\
			dump_entry_trace(entry);			\
			dump_entry_trace(entry);			\
		}							\
		}							\
		if (!show_all_errors && show_num_errors > 0)		\
		if (!show_all_errors && show_num_errors > 0)		\