From patchwork Sun Oct 2 07:04:16 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 677474 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3smx4v2zjdz9sC3 for ; Sun, 2 Oct 2016 18:04:47 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752134AbcJBHE0 (ORCPT ); Sun, 2 Oct 2016 03:04:26 -0400 Received: from smtp03.smtpout.orange.fr ([80.12.242.125]:51071 "EHLO smtp.smtpout.orange.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751372AbcJBHEZ (ORCPT ); Sun, 2 Oct 2016 03:04:25 -0400 Received: from localhost.localdomain ([92.140.239.217]) by mwinf5d26 with ME id qX4M1t0034i7a8U03X4MvR; Sun, 02 Oct 2016 09:04:22 +0200 X-ME-Helo: localhost.localdomain X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sun, 02 Oct 2016 09:04:22 +0200 X-ME-IP: 92.140.239.217 From: Christophe JAILLET To: richardcochran@gmail.com Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET Subject: [PATCH] ptp: Fix resource leak in case of error Date: Sun, 2 Oct 2016 09:04:16 +0200 Message-Id: <1475391856-15046-1-git-send-email-christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.7.4 X-Antivirus: avast! (VPS 161001-4, 01/10/2016), Outbound message X-Antivirus-Status: Clean Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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 Acked-by: Richard Cochran --- 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: