Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754595AbbKLM32 (ORCPT ); Thu, 12 Nov 2015 07:29:28 -0500 Received: from mail-wm0-f49.google.com ([74.125.82.49]:33085 "EHLO mail-wm0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752487AbbKLM30 (ORCPT ); Thu, 12 Nov 2015 07:29:26 -0500 Date: Thu, 12 Nov 2015 13:29:23 +0100 From: Thierry Reding To: LABBE Corentin Cc: gnurou@gmail.com, ldewangan@nvidia.com, swarren@wwwdotorg.org, wsa@the-dreams.de, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, linux-tegra@vger.kernel.org Subject: Re: [PATCH] i2c: tegra: fix a possible NULL dereference Message-ID: <20151112122923.GA31671@ulmo> References: <1447313163-23848-1-git-send-email-clabbe.montjoie@gmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="WIyZ46R2i8wDzkSu" Content-Disposition: inline In-Reply-To: <1447313163-23848-1-git-send-email-clabbe.montjoie@gmail.com> User-Agent: Mutt/1.5.23+102 (2ca89bed6448) (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2587 Lines: 73 --WIyZ46R2i8wDzkSu Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Nov 12, 2015 at 08:26:03AM +0100, LABBE Corentin wrote: > of_match_device could return NULL, and so cause a NULL pointer No. There is no way that of_match_device() can ever fail. The driver core uses the same table to match the OF device to the driver, so the only case where of_match_device() would return NULL is if no match was found, in which case the tegra_i2c_probe() function would never have been called in the first place. Thierry > dereference later at line 809: > i2c_dev->hw =3D match->data; >=20 > Signed-off-by: LABBE Corentin > --- > drivers/i2c/busses/i2c-tegra.c | 3 +++ > 1 file changed, 3 insertions(+) >=20 > diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegr= a.c > index a0522fc..c803551 100644 > --- a/drivers/i2c/busses/i2c-tegra.c > +++ b/drivers/i2c/busses/i2c-tegra.c > @@ -806,7 +806,10 @@ static int tegra_i2c_probe(struct platform_device *p= dev) > =20 > if (pdev->dev.of_node) { > const struct of_device_id *match; > + > match =3D of_match_device(tegra_i2c_of_match, &pdev->dev); > + if (!match) > + return -ENODEV; > i2c_dev->hw =3D match->data; > i2c_dev->is_dvc =3D of_device_is_compatible(pdev->dev.of_node, > "nvidia,tegra20-i2c-dvc"); > --=20 > 2.4.10 >=20 --WIyZ46R2i8wDzkSu Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAABCAAGBQJWRIYjAAoJEN0jrNd/PrOhbQcQAL0jAQVQhVwTtPNeHxdbsbqk m4Z9EyUE8C/J+l/mHTKnxiRFEww+EM7azrVS4ywMjuLxZxJJfBDdFf1rbCG96byl DKrGEi5r16dX8FJ3yD1mcLQxX75LNqK8T0QnZroN9HMHfivX81hejOsU8HMBfFwb PC3xQFHH0Kd54qmWwUz9O2bSBPeiNf+lucVSxyCpYGjbXCCY9jbloYYV0dwjIu4H 8HliRYtAOknnl7UaDnq1Osei0JFggidA5SLg4+CFqsSPPKf5Rhm3ZzAGyK/5EbQv cv+OfjTzMNhKG9T8PL9g6Z1z+CGYDbht+gXPEG8rFOgA7aTNv8MyK2BYPsomsVnW j24Udl5rzMg8Lh2o7Epgaa5dOWj/n6ltIH5TidkpUjI3SJYGdmDPZ9kb3EDcqC2k ZK12+3elYRT1ZnnPy4DYqUAlZvpCpbpTBVZQYlrwvuZAS7yj8JmmRt/OL1vY8Ok+ oJs+eIut4Dmy0xqeZ5yFBkwzggj64+jZLf16ERb6ZqzUQttt/FzEpu1JStgBVoSz JrLfgHi3iPTcungHRM5xEfgshtAfwGdGF/jhBlhg0bEzk5BZaZyXtaMbA6Zmre4F SlG8PtdI9OYr6E9iXyP05ShR518aIuqZ0whD0jW2fubhoCyP0Y/cqJ7gdkwaTQjW Aaxp0a72O21wrORE65G1 =45KG -----END PGP SIGNATURE----- --WIyZ46R2i8wDzkSu-- -- 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/