lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <xa1tr3yp2bse.fsf@mina86.com>
Date:	Fri, 03 Oct 2014 21:28:17 +0200
From:	Michal Nazarewicz <mina86@...a86.com>
To:	Andrew Morton <akpm@...ux-foundation.org>,
	Stephen Rothwell <sfr@...b.auug.org.au>,
	Marek Szyprowski <m.szyprowski@...sung.com>
Cc:	linux-next@...r.kernel.org, linux-kernel@...r.kernel.org,
	Arnd Bergmann <arnd@...db.de>,
	Grant Likely <grant.likely@...aro.org>,
	Laura Abbott <lauraa@...eaurora.org>,
	Josh Cartwright <joshc@...eaurora.org>,
	Joonsoo Kim <iamjoonsoo.kim@....com>,
	Kyungmin Park <kyungmin.park@...sung.com>
Subject: Re: linux-next: build warnings after merge of the akpm-current tree

On Fri, Oct 03 2014, Andrew Morton wrote:
> On Fri, 3 Oct 2014 17:30:04 +1000 Stephen Rothwell <sfr@...b.auug.org.au> wrote:
>
>> Hi Andrew,
>> 
>> After merging the akpm-current tree, today's linux-next build (arm
>> multi_v7_defconfig) produced these warnings:
>> 
>> drivers/base/dma-contiguous.c:244:2: warning: initialization from incompatible pointer type
>>   .device_init = rmem_cma_device_init,
>>   ^
>> drivers/base/dma-contiguous.c:244:2: warning: (near initialization for 'rmem_cma_ops.device_init')
>> drivers/base/dma-coherent.c:303:2: warning: initialization from incompatible pointer type
>>   .device_init = rmem_dma_device_init,
>>   ^
>> 
>> Introduced by commit e92f6296f3a2 ("drivers: dma-coherent: add
>> initialization from device tree").  This init routine is supposed to
>> return void ...
>
> I'm a bit reluctant to just go in and change rmem_cma_device_init().
>
> Why does it test for rmem->priv==NULL?  Can that really happen?  Why? 
> Is it a legitimate state?

I don't think so, since:

static int __init rmem_cma_setup(struct reserved_mem *rmem)
{
	[…]
	rmem->ops = &rmem_cma_ops;
	rmem->priv = cma;
	[…]
}

The following should fix the warning:

diff --git a/drivers/base/dma-contiguous.c b/drivers/base/dma-contiguous.c
index 6c42289..a9a88b6 100644
--- a/drivers/base/dma-contiguous.c
+++ b/drivers/base/dma-contiguous.c
@@ -223,14 +223,9 @@ bool dma_release_from_contiguous(struct device *dev, struct page *pages,
 #undef pr_fmt
 #define pr_fmt(fmt) fmt
 
-static int rmem_cma_device_init(struct reserved_mem *rmem, struct device *dev)
+static void rmem_cma_device_init(struct reserved_mem *rmem, struct device *dev)
 {
-	struct cma *cma = rmem->priv;
-
-	if (!cma)
-		return -ENODEV;
-
-	dev_set_cma_area(dev, cma);
+	dev_set_cma_area(dev, rmem->priv);
 	return 0;
 }

Even if rmem->priv is NULL, the call will simply clear device's
cma_area, but at this point it should be NULL anyway.
 
> And why does dev_set_cma_area() test for dev==NULL?  Can that really
> happen?  Is it legitimate?  Is all this stuff just papering over other
> bugs?

I believe since a2547380393ac82c659b40182b0da8d05a8365f3 dev no longer
can be NULL.  It should be safe to apply this:

diff --git a/include/linux/dma-contiguous.h b/include/linux/dma-contiguous.h
index 569bbd0..ff9804e 100644
--- a/include/linux/dma-contiguous.h
+++ b/include/linux/dma-contiguous.h
@@ -71,8 +71,7 @@ static inline struct cma *dev_get_cma_area(struct device *dev)
 
 static inline void dev_set_cma_area(struct device *dev, struct cma *cma)
 {
-	if (dev)
-		dev->cma_area = cma;
+	dev->cma_area = cma;
 }
 
 static inline void dma_contiguous_set_default(struct cma *cma)

>
> The whole thing could do with a bit of an audit and cleanup, I suspect.
> Get the states and initialization sequences and error checking all
> sorted out, then get rid of all these tests for NULL.
>

-- 
Best regards,                                         _     _
.o. | Liege of Serenely Enlightened Majesty of      o' \,=./ `o
..o | Computer Science,  Michał “mina86” Nazarewicz    (o o)
ooo +--<mpn@...gle.com>--<xmpp:mina86@...ber.org>--ooO--(_)--Ooo--
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ