* [PATCH] libnvdimm: remove redundant assignment to pointer 'dev'
@ 2018-02-05 14:08 ` Colin King
0 siblings, 0 replies; 15+ messages in thread
From: Colin King @ 2018-02-05 14:08 UTC (permalink / raw)
To: Dan Williams, linux-nvdimm; +Cc: kernel-janitors, linux-kernel
From: Colin Ian King <colin.king@canonical.com>
Pointer dev is being assigned a value that is never read, it is being
re-assigned the same value later on, hence the initialization is redundant
and can be removed.
Cleans up clang warning:
drivers/nvdimm/pfn_devs.c:307:17: warning: Value stored to 'dev' during
its initialization is never read
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
drivers/nvdimm/pfn_devs.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/nvdimm/pfn_devs.c b/drivers/nvdimm/pfn_devs.c
index f5c4e8c6e29d..2f4d18752c97 100644
--- a/drivers/nvdimm/pfn_devs.c
+++ b/drivers/nvdimm/pfn_devs.c
@@ -304,7 +304,7 @@ static const struct attribute_group *nd_pfn_attribute_groups[] = {
struct device *nd_pfn_devinit(struct nd_pfn *nd_pfn,
struct nd_namespace_common *ndns)
{
- struct device *dev = &nd_pfn->dev;
+ struct device *dev;
if (!nd_pfn)
return NULL;
--
2.15.1
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH] libnvdimm: remove redundant assignment to pointer 'dev'
@ 2018-02-05 14:08 ` Colin King
0 siblings, 0 replies; 15+ messages in thread
From: Colin King @ 2018-02-05 14:08 UTC (permalink / raw)
To: Dan Williams, linux-nvdimm; +Cc: kernel-janitors, linux-kernel
From: Colin Ian King <colin.king@canonical.com>
Pointer dev is being assigned a value that is never read, it is being
re-assigned the same value later on, hence the initialization is redundant
and can be removed.
Cleans up clang warning:
drivers/nvdimm/pfn_devs.c:307:17: warning: Value stored to 'dev' during
its initialization is never read
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
drivers/nvdimm/pfn_devs.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/nvdimm/pfn_devs.c b/drivers/nvdimm/pfn_devs.c
index f5c4e8c6e29d..2f4d18752c97 100644
--- a/drivers/nvdimm/pfn_devs.c
+++ b/drivers/nvdimm/pfn_devs.c
@@ -304,7 +304,7 @@ static const struct attribute_group *nd_pfn_attribute_groups[] = {
struct device *nd_pfn_devinit(struct nd_pfn *nd_pfn,
struct nd_namespace_common *ndns)
{
- struct device *dev = &nd_pfn->dev;
+ struct device *dev;
if (!nd_pfn)
return NULL;
--
2.15.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH] libnvdimm: remove redundant assignment to pointer 'dev'
@ 2018-02-05 14:08 ` Colin King
0 siblings, 0 replies; 15+ messages in thread
From: Colin King @ 2018-02-05 14:08 UTC (permalink / raw)
To: Dan Williams, linux-nvdimm; +Cc: kernel-janitors, linux-kernel
From: Colin Ian King <colin.king@canonical.com>
Pointer dev is being assigned a value that is never read, it is being
re-assigned the same value later on, hence the initialization is redundant
and can be removed.
Cleans up clang warning:
drivers/nvdimm/pfn_devs.c:307:17: warning: Value stored to 'dev' during
its initialization is never read
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
drivers/nvdimm/pfn_devs.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/nvdimm/pfn_devs.c b/drivers/nvdimm/pfn_devs.c
index f5c4e8c6e29d..2f4d18752c97 100644
--- a/drivers/nvdimm/pfn_devs.c
+++ b/drivers/nvdimm/pfn_devs.c
@@ -304,7 +304,7 @@ static const struct attribute_group *nd_pfn_attribute_groups[] = {
struct device *nd_pfn_devinit(struct nd_pfn *nd_pfn,
struct nd_namespace_common *ndns)
{
- struct device *dev = &nd_pfn->dev;
+ struct device *dev;
if (!nd_pfn)
return NULL;
--
2.15.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH] libnvdimm: remove redundant assignment to pointer 'dev'
2018-02-05 14:08 ` Colin King
(?)
@ 2018-02-05 18:20 ` Ross Zwisler
-1 siblings, 0 replies; 15+ messages in thread
From: Ross Zwisler @ 2018-02-05 18:20 UTC (permalink / raw)
To: Colin King; +Cc: kernel-janitors, linux-kernel, linux-nvdimm
On Mon, Feb 05, 2018 at 02:08:52PM +0000, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Pointer dev is being assigned a value that is never read, it is being
> re-assigned the same value later on, hence the initialization is redundant
> and can be removed.
>
> Cleans up clang warning:
> drivers/nvdimm/pfn_devs.c:307:17: warning: Value stored to 'dev' during
> its initialization is never read
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
Reviewed-by: Ross Zwisler <ross.zwisler@linux.intel.com>
More importantly this fixes a potential NULL pointer dereference. nd_pfn
is checked for NULL a few lines down, but we would have crashed here trying to
get nd_pfn->dev.
We can append the above info to the changelog when we apply.
> ---
> drivers/nvdimm/pfn_devs.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/nvdimm/pfn_devs.c b/drivers/nvdimm/pfn_devs.c
> index f5c4e8c6e29d..2f4d18752c97 100644
> --- a/drivers/nvdimm/pfn_devs.c
> +++ b/drivers/nvdimm/pfn_devs.c
> @@ -304,7 +304,7 @@ static const struct attribute_group *nd_pfn_attribute_groups[] = {
> struct device *nd_pfn_devinit(struct nd_pfn *nd_pfn,
> struct nd_namespace_common *ndns)
> {
> - struct device *dev = &nd_pfn->dev;
> + struct device *dev;
>
> if (!nd_pfn)
> return NULL;
> --
> 2.15.1
>
> _______________________________________________
> Linux-nvdimm mailing list
> Linux-nvdimm@lists.01.org
> https://lists.01.org/mailman/listinfo/linux-nvdimm
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH] libnvdimm: remove redundant assignment to pointer 'dev'
@ 2018-02-05 18:20 ` Ross Zwisler
0 siblings, 0 replies; 15+ messages in thread
From: Ross Zwisler @ 2018-02-05 18:20 UTC (permalink / raw)
To: Colin King; +Cc: Dan Williams, linux-nvdimm, kernel-janitors, linux-kernel
On Mon, Feb 05, 2018 at 02:08:52PM +0000, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Pointer dev is being assigned a value that is never read, it is being
> re-assigned the same value later on, hence the initialization is redundant
> and can be removed.
>
> Cleans up clang warning:
> drivers/nvdimm/pfn_devs.c:307:17: warning: Value stored to 'dev' during
> its initialization is never read
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
Reviewed-by: Ross Zwisler <ross.zwisler@linux.intel.com>
More importantly this fixes a potential NULL pointer dereference. nd_pfn
is checked for NULL a few lines down, but we would have crashed here trying to
get nd_pfn->dev.
We can append the above info to the changelog when we apply.
> ---
> drivers/nvdimm/pfn_devs.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/nvdimm/pfn_devs.c b/drivers/nvdimm/pfn_devs.c
> index f5c4e8c6e29d..2f4d18752c97 100644
> --- a/drivers/nvdimm/pfn_devs.c
> +++ b/drivers/nvdimm/pfn_devs.c
> @@ -304,7 +304,7 @@ static const struct attribute_group *nd_pfn_attribute_groups[] = {
> struct device *nd_pfn_devinit(struct nd_pfn *nd_pfn,
> struct nd_namespace_common *ndns)
> {
> - struct device *dev = &nd_pfn->dev;
> + struct device *dev;
>
> if (!nd_pfn)
> return NULL;
> --
> 2.15.1
>
> _______________________________________________
> Linux-nvdimm mailing list
> Linux-nvdimm@lists.01.org
> https://lists.01.org/mailman/listinfo/linux-nvdimm
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH] libnvdimm: remove redundant assignment to pointer 'dev'
@ 2018-02-05 18:20 ` Ross Zwisler
0 siblings, 0 replies; 15+ messages in thread
From: Ross Zwisler @ 2018-02-05 18:20 UTC (permalink / raw)
To: Colin King; +Cc: kernel-janitors, linux-kernel, linux-nvdimm
On Mon, Feb 05, 2018 at 02:08:52PM +0000, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Pointer dev is being assigned a value that is never read, it is being
> re-assigned the same value later on, hence the initialization is redundant
> and can be removed.
>
> Cleans up clang warning:
> drivers/nvdimm/pfn_devs.c:307:17: warning: Value stored to 'dev' during
> its initialization is never read
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
Reviewed-by: Ross Zwisler <ross.zwisler@linux.intel.com>
More importantly this fixes a potential NULL pointer dereference. nd_pfn
is checked for NULL a few lines down, but we would have crashed here trying to
get nd_pfn->dev.
We can append the above info to the changelog when we apply.
> ---
> drivers/nvdimm/pfn_devs.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/nvdimm/pfn_devs.c b/drivers/nvdimm/pfn_devs.c
> index f5c4e8c6e29d..2f4d18752c97 100644
> --- a/drivers/nvdimm/pfn_devs.c
> +++ b/drivers/nvdimm/pfn_devs.c
> @@ -304,7 +304,7 @@ static const struct attribute_group *nd_pfn_attribute_groups[] = {
> struct device *nd_pfn_devinit(struct nd_pfn *nd_pfn,
> struct nd_namespace_common *ndns)
> {
> - struct device *dev = &nd_pfn->dev;
> + struct device *dev;
>
> if (!nd_pfn)
> return NULL;
> --
> 2.15.1
>
> _______________________________________________
> Linux-nvdimm mailing list
> Linux-nvdimm@lists.01.org
> https://lists.01.org/mailman/listinfo/linux-nvdimm
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH] libnvdimm: remove redundant assignment to pointer 'dev'
2018-02-05 18:20 ` Ross Zwisler
(?)
@ 2018-02-05 18:44 ` Dan Williams
-1 siblings, 0 replies; 15+ messages in thread
From: Dan Williams @ 2018-02-05 18:44 UTC (permalink / raw)
To: Ross Zwisler
Cc: Colin King, kernel-janitors, Linux Kernel Mailing List, linux-nvdimm
On Mon, Feb 5, 2018 at 10:20 AM, Ross Zwisler
<ross.zwisler@linux.intel.com> wrote:
> On Mon, Feb 05, 2018 at 02:08:52PM +0000, Colin King wrote:
>> From: Colin Ian King <colin.king@canonical.com>
>>
>> Pointer dev is being assigned a value that is never read, it is being
>> re-assigned the same value later on, hence the initialization is redundant
>> and can be removed.
>>
>> Cleans up clang warning:
>> drivers/nvdimm/pfn_devs.c:307:17: warning: Value stored to 'dev' during
>> its initialization is never read
>>
>> Signed-off-by: Colin Ian King <colin.king@canonical.com>
>
> Reviewed-by: Ross Zwisler <ross.zwisler@linux.intel.com>
>
> More importantly this fixes a potential NULL pointer dereference. nd_pfn
> is checked for NULL a few lines down, but we would have crashed here trying to
> get nd_pfn->dev.
>
No we wouldn't crash. We're just calculating the address, not
de-referencing a NULL pointer.
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH] libnvdimm: remove redundant assignment to pointer 'dev'
@ 2018-02-05 18:44 ` Dan Williams
0 siblings, 0 replies; 15+ messages in thread
From: Dan Williams @ 2018-02-05 18:44 UTC (permalink / raw)
To: Ross Zwisler
Cc: Colin King, linux-nvdimm, kernel-janitors, Linux Kernel Mailing List
On Mon, Feb 5, 2018 at 10:20 AM, Ross Zwisler
<ross.zwisler@linux.intel.com> wrote:
> On Mon, Feb 05, 2018 at 02:08:52PM +0000, Colin King wrote:
>> From: Colin Ian King <colin.king@canonical.com>
>>
>> Pointer dev is being assigned a value that is never read, it is being
>> re-assigned the same value later on, hence the initialization is redundant
>> and can be removed.
>>
>> Cleans up clang warning:
>> drivers/nvdimm/pfn_devs.c:307:17: warning: Value stored to 'dev' during
>> its initialization is never read
>>
>> Signed-off-by: Colin Ian King <colin.king@canonical.com>
>
> Reviewed-by: Ross Zwisler <ross.zwisler@linux.intel.com>
>
> More importantly this fixes a potential NULL pointer dereference. nd_pfn
> is checked for NULL a few lines down, but we would have crashed here trying to
> get nd_pfn->dev.
>
No we wouldn't crash. We're just calculating the address, not
de-referencing a NULL pointer.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH] libnvdimm: remove redundant assignment to pointer 'dev'
@ 2018-02-05 18:44 ` Dan Williams
0 siblings, 0 replies; 15+ messages in thread
From: Dan Williams @ 2018-02-05 18:44 UTC (permalink / raw)
To: Ross Zwisler
Cc: Colin King, kernel-janitors, Linux Kernel Mailing List, linux-nvdimm
On Mon, Feb 5, 2018 at 10:20 AM, Ross Zwisler
<ross.zwisler@linux.intel.com> wrote:
> On Mon, Feb 05, 2018 at 02:08:52PM +0000, Colin King wrote:
>> From: Colin Ian King <colin.king@canonical.com>
>>
>> Pointer dev is being assigned a value that is never read, it is being
>> re-assigned the same value later on, hence the initialization is redundant
>> and can be removed.
>>
>> Cleans up clang warning:
>> drivers/nvdimm/pfn_devs.c:307:17: warning: Value stored to 'dev' during
>> its initialization is never read
>>
>> Signed-off-by: Colin Ian King <colin.king@canonical.com>
>
> Reviewed-by: Ross Zwisler <ross.zwisler@linux.intel.com>
>
> More importantly this fixes a potential NULL pointer dereference. nd_pfn
> is checked for NULL a few lines down, but we would have crashed here trying to
> get nd_pfn->dev.
>
No we wouldn't crash. We're just calculating the address, not
de-referencing a NULL pointer.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH] libnvdimm: remove redundant assignment to pointer 'dev'
2018-02-05 18:44 ` Dan Williams
(?)
@ 2018-02-05 20:46 ` Colin Ian King
-1 siblings, 0 replies; 15+ messages in thread
From: Colin Ian King @ 2018-02-05 20:46 UTC (permalink / raw)
To: Dan Williams, Ross Zwisler
Cc: kernel-janitors, Linux Kernel Mailing List, linux-nvdimm
On 05/02/18 18:44, Dan Williams wrote:
> On Mon, Feb 5, 2018 at 10:20 AM, Ross Zwisler
> <ross.zwisler@linux.intel.com> wrote:
>> On Mon, Feb 05, 2018 at 02:08:52PM +0000, Colin King wrote:
>>> From: Colin Ian King <colin.king@canonical.com>
>>>
>>> Pointer dev is being assigned a value that is never read, it is being
>>> re-assigned the same value later on, hence the initialization is redundant
>>> and can be removed.
>>>
>>> Cleans up clang warning:
>>> drivers/nvdimm/pfn_devs.c:307:17: warning: Value stored to 'dev' during
>>> its initialization is never read
>>>
>>> Signed-off-by: Colin Ian King <colin.king@canonical.com>
>>
>> Reviewed-by: Ross Zwisler <ross.zwisler@linux.intel.com>
>>
>> More importantly this fixes a potential NULL pointer dereference. nd_pfn
>> is checked for NULL a few lines down, but we would have crashed here trying to
>> get nd_pfn->dev.
>>
>
> No we wouldn't crash. We're just calculating the address, not
> de-referencing a NULL pointer.
Indeed, it's just a warning clean up. Nothing more.
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH] libnvdimm: remove redundant assignment to pointer 'dev'
@ 2018-02-05 20:46 ` Colin Ian King
0 siblings, 0 replies; 15+ messages in thread
From: Colin Ian King @ 2018-02-05 20:46 UTC (permalink / raw)
To: Dan Williams, Ross Zwisler
Cc: linux-nvdimm, kernel-janitors, Linux Kernel Mailing List
On 05/02/18 18:44, Dan Williams wrote:
> On Mon, Feb 5, 2018 at 10:20 AM, Ross Zwisler
> <ross.zwisler@linux.intel.com> wrote:
>> On Mon, Feb 05, 2018 at 02:08:52PM +0000, Colin King wrote:
>>> From: Colin Ian King <colin.king@canonical.com>
>>>
>>> Pointer dev is being assigned a value that is never read, it is being
>>> re-assigned the same value later on, hence the initialization is redundant
>>> and can be removed.
>>>
>>> Cleans up clang warning:
>>> drivers/nvdimm/pfn_devs.c:307:17: warning: Value stored to 'dev' during
>>> its initialization is never read
>>>
>>> Signed-off-by: Colin Ian King <colin.king@canonical.com>
>>
>> Reviewed-by: Ross Zwisler <ross.zwisler@linux.intel.com>
>>
>> More importantly this fixes a potential NULL pointer dereference. nd_pfn
>> is checked for NULL a few lines down, but we would have crashed here trying to
>> get nd_pfn->dev.
>>
>
> No we wouldn't crash. We're just calculating the address, not
> de-referencing a NULL pointer.
Indeed, it's just a warning clean up. Nothing more.
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH] libnvdimm: remove redundant assignment to pointer 'dev'
@ 2018-02-05 20:46 ` Colin Ian King
0 siblings, 0 replies; 15+ messages in thread
From: Colin Ian King @ 2018-02-05 20:46 UTC (permalink / raw)
To: Dan Williams, Ross Zwisler
Cc: kernel-janitors, Linux Kernel Mailing List, linux-nvdimm
On 05/02/18 18:44, Dan Williams wrote:
> On Mon, Feb 5, 2018 at 10:20 AM, Ross Zwisler
> <ross.zwisler@linux.intel.com> wrote:
>> On Mon, Feb 05, 2018 at 02:08:52PM +0000, Colin King wrote:
>>> From: Colin Ian King <colin.king@canonical.com>
>>>
>>> Pointer dev is being assigned a value that is never read, it is being
>>> re-assigned the same value later on, hence the initialization is redundant
>>> and can be removed.
>>>
>>> Cleans up clang warning:
>>> drivers/nvdimm/pfn_devs.c:307:17: warning: Value stored to 'dev' during
>>> its initialization is never read
>>>
>>> Signed-off-by: Colin Ian King <colin.king@canonical.com>
>>
>> Reviewed-by: Ross Zwisler <ross.zwisler@linux.intel.com>
>>
>> More importantly this fixes a potential NULL pointer dereference. nd_pfn
>> is checked for NULL a few lines down, but we would have crashed here trying to
>> get nd_pfn->dev.
>>
>
> No we wouldn't crash. We're just calculating the address, not
> de-referencing a NULL pointer.
Indeed, it's just a warning clean up. Nothing more.
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH] libnvdimm: remove redundant assignment to pointer 'dev'
2018-02-05 18:44 ` Dan Williams
(?)
@ 2018-02-05 21:35 ` Ross Zwisler
-1 siblings, 0 replies; 15+ messages in thread
From: Ross Zwisler @ 2018-02-05 21:35 UTC (permalink / raw)
To: Dan Williams
Cc: Colin King, kernel-janitors, Linux Kernel Mailing List, linux-nvdimm
On Mon, Feb 05, 2018 at 10:44:07AM -0800, Dan Williams wrote:
> On Mon, Feb 5, 2018 at 10:20 AM, Ross Zwisler
> <ross.zwisler@linux.intel.com> wrote:
> > On Mon, Feb 05, 2018 at 02:08:52PM +0000, Colin King wrote:
> >> From: Colin Ian King <colin.king@canonical.com>
> >>
> >> Pointer dev is being assigned a value that is never read, it is being
> >> re-assigned the same value later on, hence the initialization is redundant
> >> and can be removed.
> >>
> >> Cleans up clang warning:
> >> drivers/nvdimm/pfn_devs.c:307:17: warning: Value stored to 'dev' during
> >> its initialization is never read
> >>
> >> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> >
> > Reviewed-by: Ross Zwisler <ross.zwisler@linux.intel.com>
> >
> > More importantly this fixes a potential NULL pointer dereference. nd_pfn
> > is checked for NULL a few lines down, but we would have crashed here trying to
> > get nd_pfn->dev.
> >
>
> No we wouldn't crash. We're just calculating the address, not
> de-referencing a NULL pointer.
Ah, yep, you're right of course. This is exactly how offsetof() is
implemented in some architectures. Thanks.
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH] libnvdimm: remove redundant assignment to pointer 'dev'
@ 2018-02-05 21:35 ` Ross Zwisler
0 siblings, 0 replies; 15+ messages in thread
From: Ross Zwisler @ 2018-02-05 21:35 UTC (permalink / raw)
To: Dan Williams
Cc: Ross Zwisler, Colin King, linux-nvdimm, kernel-janitors,
Linux Kernel Mailing List
On Mon, Feb 05, 2018 at 10:44:07AM -0800, Dan Williams wrote:
> On Mon, Feb 5, 2018 at 10:20 AM, Ross Zwisler
> <ross.zwisler@linux.intel.com> wrote:
> > On Mon, Feb 05, 2018 at 02:08:52PM +0000, Colin King wrote:
> >> From: Colin Ian King <colin.king@canonical.com>
> >>
> >> Pointer dev is being assigned a value that is never read, it is being
> >> re-assigned the same value later on, hence the initialization is redundant
> >> and can be removed.
> >>
> >> Cleans up clang warning:
> >> drivers/nvdimm/pfn_devs.c:307:17: warning: Value stored to 'dev' during
> >> its initialization is never read
> >>
> >> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> >
> > Reviewed-by: Ross Zwisler <ross.zwisler@linux.intel.com>
> >
> > More importantly this fixes a potential NULL pointer dereference. nd_pfn
> > is checked for NULL a few lines down, but we would have crashed here trying to
> > get nd_pfn->dev.
> >
>
> No we wouldn't crash. We're just calculating the address, not
> de-referencing a NULL pointer.
Ah, yep, you're right of course. This is exactly how offsetof() is
implemented in some architectures. Thanks.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH] libnvdimm: remove redundant assignment to pointer 'dev'
@ 2018-02-05 21:35 ` Ross Zwisler
0 siblings, 0 replies; 15+ messages in thread
From: Ross Zwisler @ 2018-02-05 21:35 UTC (permalink / raw)
To: Dan Williams
Cc: Colin King, kernel-janitors, Linux Kernel Mailing List, linux-nvdimm
On Mon, Feb 05, 2018 at 10:44:07AM -0800, Dan Williams wrote:
> On Mon, Feb 5, 2018 at 10:20 AM, Ross Zwisler
> <ross.zwisler@linux.intel.com> wrote:
> > On Mon, Feb 05, 2018 at 02:08:52PM +0000, Colin King wrote:
> >> From: Colin Ian King <colin.king@canonical.com>
> >>
> >> Pointer dev is being assigned a value that is never read, it is being
> >> re-assigned the same value later on, hence the initialization is redundant
> >> and can be removed.
> >>
> >> Cleans up clang warning:
> >> drivers/nvdimm/pfn_devs.c:307:17: warning: Value stored to 'dev' during
> >> its initialization is never read
> >>
> >> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> >
> > Reviewed-by: Ross Zwisler <ross.zwisler@linux.intel.com>
> >
> > More importantly this fixes a potential NULL pointer dereference. nd_pfn
> > is checked for NULL a few lines down, but we would have crashed here trying to
> > get nd_pfn->dev.
> >
>
> No we wouldn't crash. We're just calculating the address, not
> de-referencing a NULL pointer.
Ah, yep, you're right of course. This is exactly how offsetof() is
implemented in some architectures. Thanks.
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2018-02-05 21:36 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-05 14:08 [PATCH] libnvdimm: remove redundant assignment to pointer 'dev' Colin King
2018-02-05 14:08 ` Colin King
2018-02-05 14:08 ` Colin King
2018-02-05 18:20 ` Ross Zwisler
2018-02-05 18:20 ` Ross Zwisler
2018-02-05 18:20 ` Ross Zwisler
2018-02-05 18:44 ` Dan Williams
2018-02-05 18:44 ` Dan Williams
2018-02-05 18:44 ` Dan Williams
2018-02-05 20:46 ` Colin Ian King
2018-02-05 20:46 ` Colin Ian King
2018-02-05 20:46 ` Colin Ian King
2018-02-05 21:35 ` Ross Zwisler
2018-02-05 21:35 ` Ross Zwisler
2018-02-05 21:35 ` Ross Zwisler
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.