scsi: storvsc: Use kzfree() in storvsc_suspend()
Subsystems (3)
PATCH 1/1 scsi: storvsc: Use kzfree() in storvsc_suspend()
Use kzfree() instead of memset() with 0 followed by kfree().
--- drivers/scsi/storvsc_drv.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/scsi/storvsc_drv.c +1 -4
@@ -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);
Signature · 1 line
2.26.2
Quoted 25 lines · Denis Efremov
Use
kzfree()instead ofmemset()with 0 followed bykfree().Signed-off-by Denis Efremov <[email protected]>--- drivers/scsi/storvsc_drv.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)drivers/scsi/storvsc_drv.c +1
-5@@ -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); --
Quoted 1 line
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
Quoted 8 lines
Hi Denis,
When I added the functionstorvsc_suspend()several months ago, somehow I forgot to remove the unnecessarymemset(). Sorry!The buffer is recreated in
storvsc_resume()->storvsc_connect_to_vsp()->storvsc_channel_init()->stor_device->stor_chns= kcalloc(...), so I believe thememset()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.
Quoted 1 line
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
Dexuan Cui
maintainerQuoted 11 lines
From: Denis Efremov <[email protected]>
Sent: Thursday, June 4, 2020 2:43 PMQuoted 8 lines
Hi Denis,
When I added the functionstorvsc_suspend()several months ago, somehow I forgot to remove the unnecessarymemset(). Sorry!The buffer is recreated in
storvsc_resume()->storvsc_connect_to_vsp()->storvsc_channel_init()->stor_device->stor_chns= kcalloc(...), so I believe thememset()can be safely removed.
Quoted 5 lines
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.
Quoted 7 lines
Quoted 1 line
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
Dexuan Cui
maintainerQuoted 4 lines
From: Dexuan Cui
Sent: Thursday, June 4, 2020 2:50 PMQuoted 1 line
Quoted 1 line
Can you please make a v2 patch for it and Cc my corporate email "decui" (in
Quoted 8 lines
Quoted 6 lines
To)?
Yes, of course. Could I add "Suggested-by"?
Thanks,
DenisSure.
Please also added a tag:
Thanks,
Dexuan
PATCH 1/1 scsi: storvsc: Remove memset before memory freeing in storvsc_suspend()
In reply to Dexuan-Linux CuiRemove memset with 0 for stor_device->stor_chns in storvsc_suspend() before the call to kfree() as the memory contains no sensitive information.
--- drivers/scsi/storvsc_drv.c | 3 --- 1 file changed, 3 deletions(-)
drivers/scsi/storvsc_drv.c +0 -3
@@ -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 ;
Signature · 1 line
2.26.2
RE: [PATCH] scsi: storvsc: Remove memset before memory freeing in storvsc_suspend()
Quoted 27 lines
From: Denis Efremov <[email protected]>
Sent: Friday, June 5, 2020 1:00 AM
To: Dexuan Cui <[email protected]>; Michael Kelley <[email protected]>
Cc: Denis Efremov <[email protected]>; James E . J . Bottomley <[email protected]>; Martin K . Petersen <[email protected]>; [email protected]; Linux SCSI List <[email protected]>; Linux Kernel Mailing List <[email protected]>
Subject: [PATCH] scsi: storvsc: Remove memset before memory freeing instorvsc_suspend()Remove memset with 0 for
stor_device->stor_chnsinstorvsc_suspend()before the call tokfree()as the memory contains no sensitive information.Fixes 56fb10585934 ("scsi: storvsc: Add the support of hibernation")Suggested-by Dexuan Cui <[email protected]>Signed-off-by Denis Efremov <[email protected]>--- drivers/scsi/storvsc_drv.c | 3 --- 1 file changed, 3 deletions(-)drivers/scsi/storvsc_drv.c +0
-0@@ -2035,9 +2035,6 @@ static int storvsc_suspend(struct hv_device *hv_dev)
drivers/scsi/storvsc_drv.c static int storvsc_suspend(struct hv_device
Quoted 10 lines
drivers/scsi/storvsc_drv.c +0
-4vmbus_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!
Martin K. Petersen
AppliedRe: [PATCH] scsi: storvsc: Remove memset before memory freeing in storvsc_suspend()
In reply to Denis EfremovQuoted 2 lines · Denis Efremov
Remove memset with 0 for
stor_device->stor_chnsinstorvsc_suspend()before the call tokfree()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
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering