netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ptp: Fix resource leak in case of error
@ 2016-10-02  7:04 Christophe JAILLET
  2016-10-03 14:04 ` Richard Cochran
  2016-10-04  1:54 ` David Miller
  0 siblings, 2 replies; 3+ messages in thread
From: Christophe JAILLET @ 2016-10-02  7:04 UTC (permalink / raw)
  To: richardcochran; +Cc: netdev, linux-kernel, kernel-janitors, Christophe JAILLET

A call to 'ida_simple_remove()' is missing in the error handling path.

This as been spotted with the following coccinelle script which tries to
detect missing 'ida_simple_remove()' call in error handling paths.

///////////////
@@
expression x;
identifier l;
@@

*   x = ida_simple_get(...);
    ...
    if (...) {
    ...
    }
    ...
    if (...) {
       ...
       goto l;
    }
    ...
*   l: ... when != ida_simple_remove(...);

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
Compile-tested only
---
 drivers/ptp/ptp_clock.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/ptp/ptp_clock.c b/drivers/ptp/ptp_clock.c
index 2e481b9e8ea5..86280b7e41f3 100644
--- a/drivers/ptp/ptp_clock.c
+++ b/drivers/ptp/ptp_clock.c
@@ -263,6 +263,7 @@ struct ptp_clock *ptp_clock_register(struct ptp_clock_info *info,
 no_device:
 	mutex_destroy(&ptp->tsevq_mux);
 	mutex_destroy(&ptp->pincfg_mux);
+	ida_simple_remove(&ptp_clocks_map, index);
 no_slot:
 	kfree(ptp);
 no_memory:
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] ptp: Fix resource leak in case of error
  2016-10-02  7:04 [PATCH] ptp: Fix resource leak in case of error Christophe JAILLET
@ 2016-10-03 14:04 ` Richard Cochran
  2016-10-04  1:54 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: Richard Cochran @ 2016-10-03 14:04 UTC (permalink / raw)
  To: Christophe JAILLET; +Cc: netdev, linux-kernel, kernel-janitors

On Sun, Oct 02, 2016 at 09:04:16AM +0200, Christophe JAILLET wrote:
> A call to 'ida_simple_remove()' is missing in the error handling path.
> 
> This as been spotted with the following coccinelle script which tries to
> detect missing 'ida_simple_remove()' call in error handling paths.

Acked-by: Richard Cochran <richardcochran@gmail.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] ptp: Fix resource leak in case of error
  2016-10-02  7:04 [PATCH] ptp: Fix resource leak in case of error Christophe JAILLET
  2016-10-03 14:04 ` Richard Cochran
@ 2016-10-04  1:54 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2016-10-04  1:54 UTC (permalink / raw)
  To: christophe.jaillet; +Cc: richardcochran, netdev, linux-kernel, kernel-janitors

From: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Date: Sun,  2 Oct 2016 09:04:16 +0200

> A call to 'ida_simple_remove()' is missing in the error handling path.
> 
> This as been spotted with the following coccinelle script which tries to
> detect missing 'ida_simple_remove()' call in error handling paths.
 ...
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

Applied.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-10-04  1:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-10-02  7:04 [PATCH] ptp: Fix resource leak in case of error Christophe JAILLET
2016-10-03 14:04 ` Richard Cochran
2016-10-04  1:54 ` David Miller

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).