linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: liu.h.jason@gmail.com (Jason Liu)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] net/fec: check id_entry pointer before using it
Date: Thu, 10 Mar 2011 10:41:37 +0800	[thread overview]
Message-ID: <AANLkTimMEup3ThmMpfGAWVTgsCSEyK=5Ke=+ZjJd169R@mail.gmail.com> (raw)
In-Reply-To: <20110309082601.GA3145@pengutronix.de>

Hi, Wolfram Sang,

2011/3/9 Wolfram Sang <w.sang@pengutronix.de>:
> On Wed, Mar 09, 2011 at 10:50:04AM +0800, Jason Liu wrote:
>> The id_entry will possibly be NULL, So, need check
>> id_entry and make sure it not NULL before using it.
>
> When does it become NULL?

look at the code:drivers/base/platform.c

static int platform_match(struct device *dev, struct device_driver *drv)
{
        struct platform_device *pdev = to_platform_device(dev);
        struct platform_driver *pdrv = to_platform_driver(drv);

        /* Attempt an OF style match first */
        if (of_driver_match_device(dev, drv))
                return 1;

        /* Then try to match against the id table */
        if (pdrv->id_table)
                return platform_match_id(pdrv->id_table, pdev) != NULL;

        /* fall-back to driver name match */
        return (strcmp(pdev->name, drv->name) == 0);
}

If OF style match first succeed, the function will return and the
pdev->id_entry will not get set and it's NULL.

BR,
Jason

>
> --
> Pengutronix e.K. ? ? ? ? ? ? ? ? ? ? ? ? ? | Wolfram Sang ? ? ? ? ? ? ? ?|
> Industrial Linux Solutions ? ? ? ? ? ? ? ? | http://www.pengutronix.de/ ?|
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.10 (GNU/Linux)
>
> iEYEARECAAYFAk13OZkACgkQD27XaX1/VRsZgwCeKCNK0ufdrV2186pKO3jD9qfI
> HcQAn1zZ+Rmv+rpHHQH9JNyMQitNQdXV
> =Ha2Y
> -----END PGP SIGNATURE-----
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
>
>

  reply	other threads:[~2011-03-10  2:41 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-09  2:50 [PATCH] net/fec: check id_entry pointer before using it Jason Liu
2011-03-09  5:56 ` Shawn Guo
2011-03-09  8:26 ` Wolfram Sang
2011-03-10  2:41   ` Jason Liu [this message]
2011-03-12 16:11     ` Wolfram Sang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='AANLkTimMEup3ThmMpfGAWVTgsCSEyK=5Ke=+ZjJd169R@mail.gmail.com' \
    --to=liu.h.jason@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).