Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1683488 > unrolled thread
| Started by | Amitoj Kaur Chawla <amitoj1606@gmail.com> |
|---|---|
| First post | 2017-07-08 02:50 +0200 |
| Last post | 2017-07-09 01:00 +0200 |
| Articles | 3 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH 2/2] staging: media: atomisp2: Replace kfree()/vfree() with kvfree() Amitoj Kaur Chawla <amitoj1606@gmail.com> - 2017-07-08 02:50 +0200
Re: [PATCH 2/2] staging: media: atomisp2: Replace kfree()/vfree() with kvfree() Bernd Petrovitsch <bernd@petrovitsch.priv.at> - 2017-07-08 11:00 +0200
Re: [PATCH 2/2] staging: media: atomisp2: Replace kfree()/vfree() with kvfree() Amitoj Kaur Chawla <amitoj1606@gmail.com> - 2017-07-09 01:00 +0200
| From | Amitoj Kaur Chawla <amitoj1606@gmail.com> |
|---|---|
| Date | 2017-07-08 02:50 +0200 |
| Subject | [PATCH 2/2] staging: media: atomisp2: Replace kfree()/vfree() with kvfree() |
| Message-ID | <u0M6C-3qm-7@gated-at.bofh.it> |
Conditionally calling kfree()/vfree() can be replaced by a call to
kvfree() which handles both kmalloced memory and vmalloced memory.
Consequently removed an unnecessary comment.
The Coccinelle semantic patch used to make the change is as follows:
//<smpl>
@@
expression a;
@@
- if(...) { vfree(a); }
- else { kfree(a); }
+ kvfree(a);
@@
expression a;
@@
- if(...) { kfree(a); }
- else { vfree(a); }
+ kvfree(a);
// </smpl>
Signed-off-by: Amitoj Kaur Chawla <amitoj1606@gmail.com>
---
drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
index 97093ba..a156dd424 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
@@ -117,11 +117,7 @@ void *atomisp_kernel_zalloc(size_t bytes, bool zero_mem)
*/
void atomisp_kernel_free(void *ptr)
{
- /* Verify if buffer was allocated by vmalloc() or kmalloc() */
- if (is_vmalloc_addr(ptr))
- vfree(ptr);
- else
- kfree(ptr);
+ kvfree(ptr);
}
/*
--
2.7.4
[toc] | [next] | [standalone]
| From | Bernd Petrovitsch <bernd@petrovitsch.priv.at> |
|---|---|
| Date | 2017-07-08 11:00 +0200 |
| Subject | Re: [PATCH 2/2] staging: media: atomisp2: Replace kfree()/vfree() with kvfree() |
| Message-ID | <u0TKN-8pp-11@gated-at.bofh.it> |
| In reply to | #1683488 |
On Fri, 2017-07-07 at 20:41 -0400, Amitoj Kaur Chawla wrote:
[...]
> --- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
> +++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
> @@ -117,11 +117,7 @@ void *atomisp_kernel_zalloc(size_t bytes, bool
> zero_mem)
> */
> void atomisp_kernel_free(void *ptr)
> {
> - /* Verify if buffer was allocated by vmalloc() or kmalloc()
> */
> - if (is_vmalloc_addr(ptr))
> - vfree(ptr);
> - else
> - kfree(ptr);
> + kvfree(ptr);
> }
>
> /*
Why not get rid of the trivial wrapper function completely?
MfG,
Bernd
--
Bernd Petrovitsch Email : bernd@petrovitsch.priv.at
LUGA : http://www.luga.at
[toc] | [prev] | [next] | [standalone]
| From | Amitoj Kaur Chawla <amitoj1606@gmail.com> |
|---|---|
| Date | 2017-07-09 01:00 +0200 |
| Subject | Re: [PATCH 2/2] staging: media: atomisp2: Replace kfree()/vfree() with kvfree() |
| Message-ID | <u16RH-87c-9@gated-at.bofh.it> |
| In reply to | #1683567 |
On Sat, Jul 8, 2017 at 4:58 AM, Bernd Petrovitsch
<bernd@petrovitsch.priv.at> wrote:
> On Fri, 2017-07-07 at 20:41 -0400, Amitoj Kaur Chawla wrote:
> [...]
>> --- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
>> +++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
>> @@ -117,11 +117,7 @@ void *atomisp_kernel_zalloc(size_t bytes, bool
>> zero_mem)
>> */
>> void atomisp_kernel_free(void *ptr)
>> {
>> - /* Verify if buffer was allocated by vmalloc() or kmalloc()
>> */
>> - if (is_vmalloc_addr(ptr))
>> - vfree(ptr);
>> - else
>> - kfree(ptr);
>> + kvfree(ptr);
>> }
>>
>> /*
>
> Why not get rid of the trivial wrapper function completely?
>
Oh yes, i'll send a v2.
Amitoj
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web