Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1683674
| From | "Kuppuswamy, Sathyanarayanan" <sathyaosid@gmail.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH v2 1/1] mux: mux-core: Add NULL check for dev->of_node |
| Date | 2017-07-09 01:20 +0200 |
| Message-ID | <u17b3-8t3-1@gated-at.bofh.it> (permalink) |
| References | <u0Jiq-1sx-17@gated-at.bofh.it> <u17b3-8t3-3@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
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);
>>
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH v2 1/1] mux: mux-core: Add NULL check for dev->of_node sathyanarayanan.kuppuswamy@linux.intel.com - 2017-07-07 23:50 +0200
Re: [PATCH v2 1/1] mux: mux-core: Add NULL check for dev->of_node "Kuppuswamy, Sathyanarayanan" <sathyaosid@gmail.com> - 2017-07-09 01:20 +0200
Re: [PATCH v2 1/1] mux: mux-core: Add NULL check for dev->of_node "Kuppuswamy, Sathyanarayanan" <sathyaosid@gmail.com> - 2017-07-09 09:40 +0200
Re: [PATCH v2 1/1] mux: mux-core: Add NULL check for dev->of_node sathyanarayanan kuppuswamy <sathyanarayanan.kuppuswamy@linux.intel.com> - 2017-07-10 23:40 +0200
csiph-web