Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753146AbbDUG7p (ORCPT ); Tue, 21 Apr 2015 02:59:45 -0400 Received: from hqemgate15.nvidia.com ([216.228.121.64]:10739 "EHLO hqemgate15.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752334AbbDUG7l (ORCPT ); Tue, 21 Apr 2015 02:59:41 -0400 X-PGP-Universal: processed; by hqnvupgp07.nvidia.com on Mon, 20 Apr 2015 23:58:48 -0700 Date: Tue, 21 Apr 2015 08:59:29 +0200 From: Thierry Reding To: Ricardo Ribalda Delgado CC: Bjorn Helgaas , Andrew Morton , Vivek Goyal , Vinod Koul , Cliff Wickman , Jiang Liu , Jakub Sitnicki , "Mike Travis" , LKML , Grant Likely Subject: Re: [PATCH] kernel/resource: Invalid memory access in __release_resource Message-ID: <20150421065927.GA7379@ulmo.nvidia.com> References: <1429546972-28400-1-git-send-email-ricardo.ribalda@gmail.com> <20150420192844.GD20701@google.com> <20150420203645.GE20701@google.com> MIME-Version: 1.0 In-Reply-To: X-NVConfidentiality: public User-Agent: Mutt/1.5.23 (2014-03-12) X-Originating-IP: [10.2.70.18] X-ClientProxiedBy: UKMAIL101.nvidia.com (10.26.138.13) To UKMAIL101.nvidia.com (10.26.138.13) Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="ibTvN161/egqYuK8" Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2971 Lines: 71 --ibTvN161/egqYuK8 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Apr 20, 2015 at 10:49:28PM +0200, Ricardo Ribalda Delgado wrote: > Hello >=20 > On Mon, Apr 20, 2015 at 10:36 PM, Bjorn Helgaas wro= te: >=20 > >> > From reading drivers/base/platform.c, it looks like the intent is > >> > that platform device users would use these interfaces: > >> > >> I can take a look to modify OF to use insert_resource(), but I still > >> think that no matter what, we should add this extra check, like the > >> propossed patch or maybe with a BUG_ON().... > > > > I think it would be nicer to make OF use platform_device_add_resources() > > and platform_device_add() because then there's less duplication of code. > > But Grant might have had a reason for avoiding that. > > > > Bjorn >=20 > I think I am going to make two patches, one modifying OF as you > suggest, and another one > adding a BUG_ON to release_resource. Then you can decide to apply one > or two with the feedback from Grant I don't see the point in using BUG_ON() here. That's going to crash the system anyway, so you could just as well let it crash while it's trying to dereference the parent pointer. Maybe a WARN_ON() along with an appropriate error code would be better here. As to the underlying problem, perhaps of_device_add() should be calling platform_device_add() rather than device_add()? Essentially the OF glue creates regular platform devices, so I think it should be reusing as much of the platform code as possible. From a quick look that might be somewhat hairy to do, but on the other hand these kinds of problems are bound to happen over and over again because both implementations of platform devices need to be manually kept in sync. Thierry --ibTvN161/egqYuK8 Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAABCAAGBQJVNfVNAAoJEN0jrNd/PrOhnv0P/RP8VQjX7OUSXQw1emZPIN4n fd/o6xyuPeNlyVMaPbptS/JUeoDWLJuWhq6lxZW2BmPldXlLvRwrLuAlhjXUOl4J 8UWnQCHzTzgqz8noxVYOXQVIm2Ir3Nu9v7MxuvNBEFq0l5wtzH9tqY1jj8n/5Bt6 7Gdg6hFYfsvgrdFt4YjqGuaz5k/tpob3Sx+R7eXB8Cv+nPXsVSIpnjLHwjZxQ5A1 JU7B4dJv2kMJGQPOEKgSfGTwZtJr0OLqQE9AaUJVOXw7Yo0PgBT7Ny6t6ZCYpHfn OXbqaJ9Lw3ClWkOylyCp9UGk9ilZsi+RJf4pmT5iOdFx8kXQ12g9Y8wLhSxNsLk8 QUtn+ZaSZcM9FcW4dJY+B61pJtm22l8wsL4tFQ0XjQ9KOUN6ftSg9/uSoMT4Jdh5 x3mwoV+6KFv3JkWMYsZqYJz+vAwbEhUFUnx8rJWYgv4Ip4UOJxmRyggVitL7IJdD u1tboJVgFOwtHohmX0C5lmZMkYQxoDgvoCwoMt4YzFJxMo6CXGpV8g2XRN8OEUDE GWlyo0eJg+lnvBUFgQV5oGyG4uebp0KSsgfiAd+CSYoIuYu0lOtQZunlAx7gtkur V8ZV4so9pibxOOIaKtzTA4ZZGLHCDrNORcf6h91BY4OyZZIUmz5NCurQZs46R2ij gb0HJUx8uzukjTb15FpJ =0msz -----END PGP SIGNATURE----- --ibTvN161/egqYuK8-- -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/