From: "Kuppuswamy, Sathyanarayanan" <sathyaosid@gmail.com>
To: Peter Rosin <peda@axentia.se>,
sathyanarayanan.kuppuswamy@linux.intel.com
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/1] mux: mux-core: Add NULL check for dev->of_node
Date: Sat, 8 Jul 2017 16:12:42 -0700 [thread overview]
Message-ID: <4a9a39dd-86b0-9485-46f1-76f4f8f5a809@gmail.com> (raw)
In-Reply-To: <f816564f-5731-bfab-ef15-144ac7afc60f@axentia.se>
Hi Peter,
On 7/8/2017 2:00 PM, Peter Rosin wrote:
> On 2017-07-07 23:46, sathyanarayanan.kuppuswamy@linux.intel.com wrote:
>> From: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
>>
>> If dev->of_node is NULL, then calling mux_control_get()
>> function can lead to NULL pointer exception. So adding
>> a NULL check for dev->of_node.
>>
>> Signed-off-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
> Do you have a driver that might call mux_control_get and not have any
> of_node?
For non-device tree drivers, this case is valid. I hit this issue when I
was working on Intel USB MUX driver.
> If not, I don't see the point of this check.
Since this is an API for other consumers, I think its better to have
some sanity checks.
If a non device tree driver call this API , I think its better to fail
with some error no instead of creating null pointer exception.
>
> Cheers,
> peda
>
>> ---
>> drivers/mux/mux-core.c | 3 +++
>> 1 file changed, 3 insertions(+)
>>
>> Changes since v1:
>> * Removed dummy new line.
>>
>> diff --git a/drivers/mux/mux-core.c b/drivers/mux/mux-core.c
>> index 90b8995..924c983 100644
>> --- a/drivers/mux/mux-core.c
>> +++ b/drivers/mux/mux-core.c
>> @@ -438,6 +438,9 @@ struct mux_control *mux_control_get(struct device *dev, const char *mux_name)
>> int index = 0;
>> int ret;
>>
>> + if (!np)
>> + return ERR_PTR(-ENODEV);
>> +
>> if (mux_name) {
>> index = of_property_match_string(np, "mux-control-names",
>> mux_name);
>>
next prev parent reply other threads:[~2017-07-08 23:12 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-07 21:46 sathyanarayanan.kuppuswamy
2017-07-08 21:00 ` Peter Rosin
2017-07-08 23:12 ` Kuppuswamy, Sathyanarayanan [this message]
2017-07-09 7:07 ` Peter Rosin
2017-07-09 7:35 ` Kuppuswamy, Sathyanarayanan
2017-07-10 7:40 ` Peter Rosin
2017-07-10 21:36 ` sathyanarayanan kuppuswamy
2017-07-12 9:14 ` Peter Rosin
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=4a9a39dd-86b0-9485-46f1-76f4f8f5a809@gmail.com \
--to=sathyaosid@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=peda@axentia.se \
--cc=sathyanarayanan.kuppuswamy@linux.intel.com \
/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
all inboxes | Powered by JetHome®