* [PATCH] NFC: nci: fix memory leak
@ 2015-11-16 12:57 Sudip Mukherjee
2015-12-09 11:59 ` Sudip Mukherjee
0 siblings, 1 reply; 2+ messages in thread
From: Sudip Mukherjee @ 2015-11-16 12:57 UTC (permalink / raw)
To: Lauro Ramos Venancio, Aloisio Almeida Jr, Samuel Ortiz,
David S. Miller
Cc: linux-kernel, linux-wireless, netdev, Sudip Mukherjee
In case of invalid number_destination_params we were returning error but
we missed releasing cmd. Lets check for the number of parameter before
allocating memory so that we don't have a memory leak.
Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
---
net/nfc/nci/core.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/net/nfc/nci/core.c b/net/nfc/nci/core.c
index 10c99a5..fbb7a2b 100644
--- a/net/nfc/nci/core.c
+++ b/net/nfc/nci/core.c
@@ -610,14 +610,14 @@ int nci_core_conn_create(struct nci_dev *ndev, u8 destination_type,
struct nci_core_conn_create_cmd *cmd;
struct core_conn_create_data data;
+ if (!number_destination_params)
+ return -EINVAL;
+
data.length = params_len + sizeof(struct nci_core_conn_create_cmd);
cmd = kzalloc(data.length, GFP_KERNEL);
if (!cmd)
return -ENOMEM;
- if (!number_destination_params)
- return -EINVAL;
-
cmd->destination_type = destination_type;
cmd->number_destination_params = number_destination_params;
memcpy(cmd->params, params, params_len);
--
1.9.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] NFC: nci: fix memory leak
2015-11-16 12:57 [PATCH] NFC: nci: fix memory leak Sudip Mukherjee
@ 2015-12-09 11:59 ` Sudip Mukherjee
0 siblings, 0 replies; 2+ messages in thread
From: Sudip Mukherjee @ 2015-12-09 11:59 UTC (permalink / raw)
To: Lauro Ramos Venancio, Aloisio Almeida Jr, Samuel Ortiz,
David S. Miller
Cc: linux-kernel, linux-wireless, netdev
On Mon, Nov 16, 2015 at 06:27:15PM +0530, Sudip Mukherjee wrote:
> In case of invalid number_destination_params we were returning error but
> we missed releasing cmd. Lets check for the number of parameter before
> allocating memory so that we don't have a memory leak.
>
> Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
> ---
A gentle ping.
regards
sudip
> net/nfc/nci/core.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/net/nfc/nci/core.c b/net/nfc/nci/core.c
> index 10c99a5..fbb7a2b 100644
> --- a/net/nfc/nci/core.c
> +++ b/net/nfc/nci/core.c
> @@ -610,14 +610,14 @@ int nci_core_conn_create(struct nci_dev *ndev, u8 destination_type,
> struct nci_core_conn_create_cmd *cmd;
> struct core_conn_create_data data;
>
> + if (!number_destination_params)
> + return -EINVAL;
> +
> data.length = params_len + sizeof(struct nci_core_conn_create_cmd);
> cmd = kzalloc(data.length, GFP_KERNEL);
> if (!cmd)
> return -ENOMEM;
>
> - if (!number_destination_params)
> - return -EINVAL;
> -
> cmd->destination_type = destination_type;
> cmd->number_destination_params = number_destination_params;
> memcpy(cmd->params, params, params_len);
> --
> 1.9.1
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-12-09 11:59 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-16 12:57 [PATCH] NFC: nci: fix memory leak Sudip Mukherjee
2015-12-09 11:59 ` Sudip Mukherjee
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).