s2255drv: fix memory leak s2255_probe()
PATCH 1/1 s2255drv: fix memory leak s2255_probe()
smatch says:
drivers/media/usb/s2255/s2255drv.c:2246 s2255_probe() warn:
possible memory leak of 'dev'
--- drivers/media/usb/s2255/s2255drv.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
drivers/media/usb/s2255/s2255drv.c +1 -0
@@ -2243,6 +2243,7 @@ static int s2255_probe(struct usb_interface *interface, dev->cmdbuf =kzalloc (S2255_CMDBUF_SIZE ,GFP_KERNEL );if (dev->cmdbuf ==NULL ) {s2255_dev_err (&interface->dev,"out of memory\n" ); +kfree (dev);return -ENOMEM ; }
Signature · 1 line
1.7.4.4
Hi Daeseok,
Quoted 15 lines · Daeseok Youn
smatch says:
drivers/media/usb/s2255/s2255drv.c:2246s2255_probe()warn:
possible memory leak of 'dev'Signed-off-by Daeseok Youn <[email protected]>--- drivers/media/usb/s2255/s2255drv.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)drivers/media/usb/s2255/s2255drv.c +0
-0
drivers/media/usb/s2255/s2255drv.c static int s2255_probe(struct usb_interface *interface, · line 2249
Quoted 7 lines
drivers/media/usb/s2255/s2255drv.c +1
-0@@ -2243,6 +2243,7 @@ static int s2255_probe(struct usb_interface *interface, dev->cmdbuf =kzalloc (S2255_CMDBUF_SIZE ,GFP_KERNEL );if (dev->cmdbuf ==NULL ) {s2255_dev_err (&interface->dev,"out of memory\n" ); +kfree (dev);return -ENOMEM ; }
The rest of the function already uses goto and labels for error handling. I think it'd take adding one more. dev is correctly released in other error cases.
What do you think?
Signature · 4 lines
Kind regards, Sakari Ailus e-mail: [email protected] XMPP: [email protected]
Hi, Sakari
2014-04-15 18:33 GMT+09:00 Sakari Ailus <[email protected]>:
Quoted 13 lines
Hi Daeseok,
Quoted 10 lines · Daeseok Youn
smatch says:
drivers/media/usb/s2255/s2255drv.c:2246s2255_probe()warn:
possible memory leak of 'dev'Signed-off-by Daeseok Youn <[email protected]>--- drivers/media/usb/s2255/s2255drv.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
Quoted 16 lines
drivers/media/usb/s2255/s2255drv.c static int s2255_probe(struct usb_interface *interface, · line 2249
Quoted 12 lines
drivers/media/usb/s2255/s2255drv.c +1
-0@@ -2243,6 +2243,7 @@ static int s2255_probe(struct usb_interface *interface, dev->cmdbuf =kzalloc (S2255_CMDBUF_SIZE ,GFP_KERNEL );if (dev->cmdbuf ==NULL ) {s2255_dev_err (&interface->dev,"out of memory\n" ); +kfree (dev);return -ENOMEM ; }The rest of the function already uses goto and labels for error handling. I think it'd take adding one more. dev is correctly released in other error cases.
I am not sure that adding a new label for error handling when allocation for dev->cmdbuf is failed.
I think it is ok to me. :-) Because I think it is not good adding a new label and use goto statement for this.
Thanks for review.
Regards,
Daeseok Youn.
Quoted 8 lines
What do you think?
--
Kind regards,Sakari Ailus
e-mail: [email protected] XMPP: [email protected]
Quoted 32 lines · DaeSeok Youn
Hi, Sakari
2014-04-15 18:33 GMT+09:00 Sakari Ailus <[email protected]>:
Quoted 13 lines
Hi Daeseok,
Quoted 10 lines · Daeseok Youn
smatch says:
drivers/media/usb/s2255/s2255drv.c:2246s2255_probe()warn:
possible memory leak of 'dev'Signed-off-by Daeseok Youn <[email protected]>--- drivers/media/usb/s2255/s2255drv.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)Quoted 16 lines
drivers/media/usb/s2255/s2255drv.c static int s2255_probe(struct usb_interface *interface, · line 2249
Quoted 12 lines
drivers/media/usb/s2255/s2255drv.c +1
-0@@ -2243,6 +2243,7 @@ static int s2255_probe(struct usb_interface *interface, dev->cmdbuf =kzalloc (S2255_CMDBUF_SIZE ,GFP_KERNEL );if (dev->cmdbuf ==NULL ) {s2255_dev_err (&interface->dev,"out of memory\n" ); +kfree (dev);return -ENOMEM ; }The rest of the function already uses goto and labels for error handling. I think it'd take adding one more. dev is correctly released in other error cases.
Quoted 4 lines
I am not sure that adding a new label for error handling when allocation for
dev->cmdbufis failed.
I think it is ok to me. :-) Because I think it is not good adding a new label and use goto statement for this.
I can ack this if you use the same pattern for error handling that's already there.
Signature · 2 lines
Sakari Ailus e-mail: [email protected] XMPP: [email protected]
Hello,
2014-05-05 17:38 GMT+09:00 Sakari Ailus <[email protected]>:
Quoted 33 lines · DaeSeok Youn
Quoted 32 lines
Hi, Sakari
2014-04-15 18:33 GMT+09:00 Sakari Ailus <[email protected]>:
Quoted 29 lines
Hi Daeseok,
Quoted 15 lines · Daeseok Youn
smatch says:
drivers/media/usb/s2255/s2255drv.c:2246s2255_probe()warn:
possible memory leak of 'dev'Signed-off-by Daeseok Youn <[email protected]>--- drivers/media/usb/s2255/s2255drv.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)drivers/media/usb/s2255/s2255drv.c +0
-0drivers/media/usb/s2255/s2255drv.c static int s2255_probe(struct usb_interface *interface, · line 2249
Quoted 7 lines
drivers/media/usb/s2255/s2255drv.c +1
-0@@ -2243,6 +2243,7 @@ static int s2255_probe(struct usb_interface *interface, dev->cmdbuf =kzalloc (S2255_CMDBUF_SIZE ,GFP_KERNEL );if (dev->cmdbuf ==NULL ) {s2255_dev_err (&interface->dev,"out of memory\n" ); +kfree (dev);return -ENOMEM ; }The rest of the function already uses goto and labels for error handling. I think it'd take adding one more. dev is correctly released in other error cases.
Quoted 7 lines
Quoted 4 lines
I am not sure that adding a new label for error handling when allocation for
dev->cmdbufis failed.
I think it is ok to me. :-) Because I think it is not good adding a new label and use goto statement for this.I can ack this if you use the same pattern for error handling that's already there.
But it has a redundant kfree() call for dev->cmdbuf when it failed to allocate, right?
If it is ok, I send this again after fixing as your comment.
Thanks.
Daeseok Youn.
Quoted 4 lines
--
Sakari Ailus
e-mail: [email protected] XMPP: [email protected]
Quoted 41 lines · DaeSeok Youn
Hello,
2014-05-05 17:38 GMT+09:00 Sakari Ailus <[email protected]>:
Quoted 38 lines · DaeSeok Youn
Quoted 36 lines
Hi, Sakari
2014-04-15 18:33 GMT+09:00 Sakari Ailus <[email protected]>:
Quoted 13 lines
Hi Daeseok,
Quoted 10 lines · Daeseok Youn
smatch says:
drivers/media/usb/s2255/s2255drv.c:2246s2255_probe()warn:
possible memory leak of 'dev'Signed-off-by Daeseok Youn <[email protected]>--- drivers/media/usb/s2255/s2255drv.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)Quoted 16 lines
drivers/media/usb/s2255/s2255drv.c static int s2255_probe(struct usb_interface *interface, · line 2249
Quoted 12 lines
drivers/media/usb/s2255/s2255drv.c +1
-0@@ -2243,6 +2243,7 @@ static int s2255_probe(struct usb_interface *interface, dev->cmdbuf =kzalloc (S2255_CMDBUF_SIZE ,GFP_KERNEL );if (dev->cmdbuf ==NULL ) {s2255_dev_err (&interface->dev,"out of memory\n" ); +kfree (dev);return -ENOMEM ; }The rest of the function already uses goto and labels for error handling. I think it'd take adding one more. dev is correctly released in other error cases.
I am not sure that adding a new label for error handling when allocation for
dev->cmdbufis failed.
I think it is ok to me. :-) Because I think it is not good adding a new label and use goto statement for this.
Quoted 4 lines
Quoted 2 lines
I can ack this if you use the same pattern for error handling that's already there.
But it has a redundant
kfree()call fordev->cmdbufwhen it failed to allocate, right?
Correct.
Quoted 1 line
If it is ok, I send this again after fixing as your comment.
Please do. Thanks.
Signature · 2 lines
Sakari Ailus e-mail: [email protected] XMPP: [email protected]