* [PATCH] scsi: storvsc: Use kzfree() in storvsc_suspend()
@ 2020-06-04 13:04 Denis Efremov
2020-06-04 17:05 ` Dexuan-Linux Cui
0 siblings, 1 reply; 8+ messages in thread
From: Denis Efremov @ 2020-06-04 13:04 UTC (permalink / raw)
To: James E.J. Bottomley
Cc: Denis Efremov, Martin K. Petersen, linux-hyperv, linux-scsi,
linux-kernel
Use kzfree() instead of memset() with 0 followed by kfree().
Signed-off-by: Denis Efremov <efremov@linux.com>
---
drivers/scsi/storvsc_drv.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c
index 072ed8728657..e5a19cd8a450 100644
--- a/drivers/scsi/storvsc_drv.c
+++ b/drivers/scsi/storvsc_drv.c
@@ -2035,10 +2035,7 @@ static int storvsc_suspend(struct hv_device *hv_dev)
vmbus_close(hv_dev->channel);
- memset(stor_device->stor_chns, 0,
- num_possible_cpus() * sizeof(void *));
-
- kfree(stor_device->stor_chns);
+ kzfree(stor_device->stor_chns);
stor_device->stor_chns = NULL;
cpumask_clear(&stor_device->alloced_cpus);
--
2.26.2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] scsi: storvsc: Use kzfree() in storvsc_suspend()
2020-06-04 13:04 [PATCH] scsi: storvsc: Use kzfree() in storvsc_suspend() Denis Efremov
@ 2020-06-04 17:05 ` Dexuan-Linux Cui
2020-06-04 21:43 ` Denis Efremov
2020-06-05 7:59 ` [PATCH] scsi: storvsc: Remove memset before memory freeing " Denis Efremov
0 siblings, 2 replies; 8+ messages in thread
From: Dexuan-Linux Cui @ 2020-06-04 17:05 UTC (permalink / raw)
To: Denis Efremov, Dexuan Cui, Michael Kelley
Cc: James E.J. Bottomley, Martin K. Petersen, linux-hyperv,
Linux SCSI List, Linux Kernel Mailing List
On Thu, Jun 4, 2020 at 6:06 AM Denis Efremov <efremov@linux.com> wrote:
>
> Use kzfree() instead of memset() with 0 followed by kfree().
>
> Signed-off-by: Denis Efremov <efremov@linux.com>
> ---
> drivers/scsi/storvsc_drv.c | 5 +----
> 1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c
> index 072ed8728657..e5a19cd8a450 100644
> --- a/drivers/scsi/storvsc_drv.c
> +++ b/drivers/scsi/storvsc_drv.c
> @@ -2035,10 +2035,7 @@ static int storvsc_suspend(struct hv_device *hv_dev)
>
> vmbus_close(hv_dev->channel);
>
> - memset(stor_device->stor_chns, 0,
> - num_possible_cpus() * sizeof(void *));
> -
> - kfree(stor_device->stor_chns);
> + kzfree(stor_device->stor_chns);
> stor_device->stor_chns = NULL;
>
> cpumask_clear(&stor_device->alloced_cpus);
> --
> 2.26.2
Hi Denis,
When I added the function storvsc_suspend() several months ago, somehow I forgot
to remove the unnecessary memset(). Sorry!
The buffer is recreated in storvsc_resume() -> storvsc_connect_to_vsp() ->
storvsc_channel_init() -> stor_device->stor_chns = kcalloc(...), so I believe
the memset() can be safely removed. Can you please make a v2 patch for it
and Cc my corporate email "decui" (in To)?
Thanks,
Dexuan
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] scsi: storvsc: Use kzfree() in storvsc_suspend()
2020-06-04 17:05 ` Dexuan-Linux Cui
@ 2020-06-04 21:43 ` Denis Efremov
2020-06-04 21:49 ` Dexuan Cui
2020-06-05 7:59 ` [PATCH] scsi: storvsc: Remove memset before memory freeing " Denis Efremov
1 sibling, 1 reply; 8+ messages in thread
From: Denis Efremov @ 2020-06-04 21:43 UTC (permalink / raw)
To: Dexuan-Linux Cui, Dexuan Cui, Michael Kelley
Cc: James E.J. Bottomley, Martin K. Petersen, linux-hyperv,
Linux SCSI List, Linux Kernel Mailing List
>
> Hi Denis,
> When I added the function storvsc_suspend() several months ago, somehow I forgot
> to remove the unnecessary memset(). Sorry!
>
> The buffer is recreated in storvsc_resume() -> storvsc_connect_to_vsp() ->
> storvsc_channel_init() -> stor_device->stor_chns = kcalloc(...), so I believe
> the memset() can be safely removed.
I'm not sure that I understand your description. As for me, memset with 0 before
memory freeing is required only for sensitive information and it's completely
unrelated to memory zeroing during allocation with kzalloc/kcalloc.
If it's not a sensitive information then memset could be safely removed.
> Can you please make a v2 patch for it and Cc my corporate email "decui" (in To)?
Yes, of course. Could I add "Suggested-by"?
Thanks,
Denis
^ permalink raw reply [flat|nested] 8+ messages in thread
* RE: [PATCH] scsi: storvsc: Use kzfree() in storvsc_suspend()
2020-06-04 21:43 ` Denis Efremov
@ 2020-06-04 21:49 ` Dexuan Cui
2020-06-04 21:51 ` Dexuan Cui
0 siblings, 1 reply; 8+ messages in thread
From: Dexuan Cui @ 2020-06-04 21:49 UTC (permalink / raw)
To: efremov, Dexuan-Linux Cui, Michael Kelley
Cc: James E.J. Bottomley, Martin K. Petersen, linux-hyperv,
Linux SCSI List, Linux Kernel Mailing List
> From: Denis Efremov <efremov@linux.com>
> Sent: Thursday, June 4, 2020 2:43 PM
> >
> > Hi Denis,
> > When I added the function storvsc_suspend() several months ago, somehow
> > I forgot to remove the unnecessary memset(). Sorry!
> >
> > The buffer is recreated in storvsc_resume() -> storvsc_connect_to_vsp() ->
> > storvsc_channel_init() -> stor_device->stor_chns = kcalloc(...), so I believe
> > the memset() can be safely removed.
>
> I'm not sure that I understand your description. As for me, memset with 0
> before
> memory freeing is required only for sensitive information and it's completely
> unrelated to memory zeroing during allocation with kzalloc/kcalloc.
> If it's not a sensitive information then memset could be safely removed.
There is no sensitive info in the buffer here.
> > Can you please make a v2 patch for it and Cc my corporate email "decui" (in
> To)?
>
> Yes, of course. Could I add "Suggested-by"?
>
> Thanks,
> Denis
Sure.
Thanks,
-- Dexuan
^ permalink raw reply [flat|nested] 8+ messages in thread
* RE: [PATCH] scsi: storvsc: Use kzfree() in storvsc_suspend()
2020-06-04 21:49 ` Dexuan Cui
@ 2020-06-04 21:51 ` Dexuan Cui
0 siblings, 0 replies; 8+ messages in thread
From: Dexuan Cui @ 2020-06-04 21:51 UTC (permalink / raw)
To: 'efremov@linux.com', 'Dexuan-Linux Cui', Michael Kelley
Cc: 'James E.J. Bottomley', 'Martin K. Petersen',
'linux-hyperv@vger.kernel.org', 'Linux SCSI List',
'Linux Kernel Mailing List'
> From: Dexuan Cui
> Sent: Thursday, June 4, 2020 2:50 PM
>
> > > Can you please make a v2 patch for it and Cc my corporate email "decui" (in
> > To)?
> >
> > Yes, of course. Could I add "Suggested-by"?
> >
> > Thanks,
> > Denis
>
> Sure.
Please also added a tag:
Fixes: 56fb10585934 ("scsi: storvsc: Add the support of hibernation")
Thanks,
Dexuan
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH] scsi: storvsc: Remove memset before memory freeing in storvsc_suspend()
2020-06-04 17:05 ` Dexuan-Linux Cui
2020-06-04 21:43 ` Denis Efremov
@ 2020-06-05 7:59 ` Denis Efremov
2020-06-05 8:07 ` Dexuan Cui
2020-06-10 2:02 ` Martin K. Petersen
1 sibling, 2 replies; 8+ messages in thread
From: Denis Efremov @ 2020-06-05 7:59 UTC (permalink / raw)
To: Dexuan Cui, Michael Kelley
Cc: Denis Efremov, James E . J . Bottomley, Martin K . Petersen,
linux-hyperv, Linux SCSI List, Linux Kernel Mailing List
Remove memset with 0 for stor_device->stor_chns in storvsc_suspend()
before the call to kfree() as the memory contains no sensitive information.
Fixes: 56fb10585934 ("scsi: storvsc: Add the support of hibernation")
Suggested-by: Dexuan Cui <decui@microsoft.com>
Signed-off-by: Denis Efremov <efremov@linux.com>
---
drivers/scsi/storvsc_drv.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c
index 072ed8728657..2d90cddd8ac2 100644
--- a/drivers/scsi/storvsc_drv.c
+++ b/drivers/scsi/storvsc_drv.c
@@ -2035,9 +2035,6 @@ static int storvsc_suspend(struct hv_device *hv_dev)
vmbus_close(hv_dev->channel);
- memset(stor_device->stor_chns, 0,
- num_possible_cpus() * sizeof(void *));
-
kfree(stor_device->stor_chns);
stor_device->stor_chns = NULL;
--
2.26.2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* RE: [PATCH] scsi: storvsc: Remove memset before memory freeing in storvsc_suspend()
2020-06-05 7:59 ` [PATCH] scsi: storvsc: Remove memset before memory freeing " Denis Efremov
@ 2020-06-05 8:07 ` Dexuan Cui
2020-06-10 2:02 ` Martin K. Petersen
1 sibling, 0 replies; 8+ messages in thread
From: Dexuan Cui @ 2020-06-05 8:07 UTC (permalink / raw)
To: Denis Efremov, Michael Kelley
Cc: James E . J . Bottomley, Martin K . Petersen, linux-hyperv,
Linux SCSI List, Linux Kernel Mailing List
> From: Denis Efremov <efremov@linux.com>
> Sent: Friday, June 5, 2020 1:00 AM
> To: Dexuan Cui <decui@microsoft.com>; Michael Kelley
> <mikelley@microsoft.com>
> Cc: Denis Efremov <efremov@linux.com>; James E . J . Bottomley
> <jejb@linux.ibm.com>; Martin K . Petersen <martin.petersen@oracle.com>;
> linux-hyperv@vger.kernel.org; Linux SCSI List <linux-scsi@vger.kernel.org>;
> Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
> Subject: [PATCH] scsi: storvsc: Remove memset before memory freeing in
> storvsc_suspend()
>
> Remove memset with 0 for stor_device->stor_chns in storvsc_suspend()
> before the call to kfree() as the memory contains no sensitive information.
>
> Fixes: 56fb10585934 ("scsi: storvsc: Add the support of hibernation")
> Suggested-by: Dexuan Cui <decui@microsoft.com>
> Signed-off-by: Denis Efremov <efremov@linux.com>
> ---
> drivers/scsi/storvsc_drv.c | 3 ---
> 1 file changed, 3 deletions(-)
>
> diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c
> index 072ed8728657..2d90cddd8ac2 100644
> --- a/drivers/scsi/storvsc_drv.c
> +++ b/drivers/scsi/storvsc_drv.c
> @@ -2035,9 +2035,6 @@ static int storvsc_suspend(struct hv_device
> *hv_dev)
>
> vmbus_close(hv_dev->channel);
>
> - memset(stor_device->stor_chns, 0,
> - num_possible_cpus() * sizeof(void *));
> -
> kfree(stor_device->stor_chns);
> stor_device->stor_chns = NULL;
>
> --
Denis, thank you for fixing this!
Reviewed-by: Dexuan Cui <decui@microsoft.com>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] scsi: storvsc: Remove memset before memory freeing in storvsc_suspend()
2020-06-05 7:59 ` [PATCH] scsi: storvsc: Remove memset before memory freeing " Denis Efremov
2020-06-05 8:07 ` Dexuan Cui
@ 2020-06-10 2:02 ` Martin K. Petersen
1 sibling, 0 replies; 8+ messages in thread
From: Martin K. Petersen @ 2020-06-10 2:02 UTC (permalink / raw)
To: Denis Efremov, Michael Kelley, Dexuan Cui
Cc: Martin K . Petersen, Linux Kernel Mailing List,
James E . J . Bottomley, linux-hyperv, Linux SCSI List
On Fri, 5 Jun 2020 10:59:34 +0300, Denis Efremov wrote:
> Remove memset with 0 for stor_device->stor_chns in storvsc_suspend()
> before the call to kfree() as the memory contains no sensitive information.
Applied to 5.8/scsi-queue, thanks!
[1/1] scsi: storvsc: Remove memset before memory freeing in storvsc_suspend()
https://git.kernel.org/mkp/scsi/c/f47c24033a1a
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2020-06-10 2:05 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-04 13:04 [PATCH] scsi: storvsc: Use kzfree() in storvsc_suspend() Denis Efremov
2020-06-04 17:05 ` Dexuan-Linux Cui
2020-06-04 21:43 ` Denis Efremov
2020-06-04 21:49 ` Dexuan Cui
2020-06-04 21:51 ` Dexuan Cui
2020-06-05 7:59 ` [PATCH] scsi: storvsc: Remove memset before memory freeing " Denis Efremov
2020-06-05 8:07 ` Dexuan Cui
2020-06-10 2:02 ` Martin K. Petersen
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).