* [PATCH][V2] reset: remove redundant null check on pointer dev
@ 2019-05-10 9:58 Colin King
2019-05-10 10:14 ` Bartosz Golaszewski
0 siblings, 1 reply; 3+ messages in thread
From: Colin King @ 2019-05-10 9:58 UTC (permalink / raw)
To: Philipp Zabel, Bartosz Golaszewski; +Cc: kernel-janitors, linux-kernel
From: Colin Ian King <colin.king@canonical.com>
Pointer dev is being dereferenced when passed to the inlined
functon dev_name, however, dev is later being null checked
so at first this seems like a potential null pointer dereference.
In fact, _reset_control_get_from_lookup is only ever called from
__reset_control_get, right after checking dev->of_node hence
dev can never be null. Clean this up by removing the redundant
null check.
Thanks to Philipp Zabel for spotting that dev can never be null.
Addresses-Coverity: ("Dereference before null check")
Fixes: 6691dffab0ab ("reset: add support for non-DT systems")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
V2: remove null check point, it is redundant.
---
drivers/reset/core.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/drivers/reset/core.c b/drivers/reset/core.c
index 81ea77cba123..921f4bbbad8a 100644
--- a/drivers/reset/core.c
+++ b/drivers/reset/core.c
@@ -694,9 +694,6 @@ __reset_control_get_from_lookup(struct device *dev, const char *con_id,
const char *dev_id = dev_name(dev);
struct reset_control *rstc = NULL;
- if (!dev)
- return ERR_PTR(-EINVAL);
-
mutex_lock(&reset_lookup_mutex);
list_for_each_entry(lookup, &reset_lookup_list, list) {
--
2.20.1
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH][V2] reset: remove redundant null check on pointer dev
2019-05-10 9:58 [PATCH][V2] reset: remove redundant null check on pointer dev Colin King
@ 2019-05-10 10:14 ` Bartosz Golaszewski
2019-05-10 10:25 ` Philipp Zabel
0 siblings, 1 reply; 3+ messages in thread
From: Bartosz Golaszewski @ 2019-05-10 10:14 UTC (permalink / raw)
To: Colin King; +Cc: Philipp Zabel, kernel-janitors, LKML
pt., 10 maj 2019 o 11:58 Colin King <colin.king@canonical.com> napisał(a):
>
> From: Colin Ian King <colin.king@canonical.com>
>
> Pointer dev is being dereferenced when passed to the inlined
> functon dev_name, however, dev is later being null checked
> so at first this seems like a potential null pointer dereference.
>
> In fact, _reset_control_get_from_lookup is only ever called from
> __reset_control_get, right after checking dev->of_node hence
> dev can never be null. Clean this up by removing the redundant
> null check.
>
> Thanks to Philipp Zabel for spotting that dev can never be null.
>
> Addresses-Coverity: ("Dereference before null check")
> Fixes: 6691dffab0ab ("reset: add support for non-DT systems")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>
> V2: remove null check point, it is redundant.
>
> ---
> drivers/reset/core.c | 3 ---
> 1 file changed, 3 deletions(-)
>
> diff --git a/drivers/reset/core.c b/drivers/reset/core.c
> index 81ea77cba123..921f4bbbad8a 100644
> --- a/drivers/reset/core.c
> +++ b/drivers/reset/core.c
> @@ -694,9 +694,6 @@ __reset_control_get_from_lookup(struct device *dev, const char *con_id,
> const char *dev_id = dev_name(dev);
> struct reset_control *rstc = NULL;
>
> - if (!dev)
> - return ERR_PTR(-EINVAL);
> -
> mutex_lock(&reset_lookup_mutex);
>
> list_for_each_entry(lookup, &reset_lookup_list, list) {
> --
> 2.20.1
>
Reviewed-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH][V2] reset: remove redundant null check on pointer dev
2019-05-10 10:14 ` Bartosz Golaszewski
@ 2019-05-10 10:25 ` Philipp Zabel
0 siblings, 0 replies; 3+ messages in thread
From: Philipp Zabel @ 2019-05-10 10:25 UTC (permalink / raw)
To: Bartosz Golaszewski, Colin King; +Cc: kernel-janitors, LKML
On Fri, 2019-05-10 at 12:14 +0200, Bartosz Golaszewski wrote:
> pt., 10 maj 2019 o 11:58 Colin King <colin.king@canonical.com> napisał(a):
> >
> > From: Colin Ian King <colin.king@canonical.com>
> >
> > Pointer dev is being dereferenced when passed to the inlined
> > functon dev_name, however, dev is later being null checked
> > so at first this seems like a potential null pointer dereference.
> >
> > In fact, _reset_control_get_from_lookup is only ever called from
> > __reset_control_get, right after checking dev->of_node hence
> > dev can never be null. Clean this up by removing the redundant
> > null check.
> >
> > Thanks to Philipp Zabel for spotting that dev can never be null.
> >
> > Addresses-Coverity: ("Dereference before null check")
> > Fixes: 6691dffab0ab ("reset: add support for non-DT systems")
> > Signed-off-by: Colin Ian King <colin.king@canonical.com>
[...]
> Reviewed-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Thank you both, applied to reset/fixes.
regards
Philipp
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-05-10 10:25 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-05-10 9:58 [PATCH][V2] reset: remove redundant null check on pointer dev Colin King
2019-05-10 10:14 ` Bartosz Golaszewski
2019-05-10 10:25 ` Philipp Zabel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox