From patchwork Mon Sep 12 06:02:13 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 668600 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 3sXcfS6lXrz9sQw for ; Mon, 12 Sep 2016 16:02:40 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932356AbcILGC1 (ORCPT ); Mon, 12 Sep 2016 02:02:27 -0400 Received: from smtp08.smtpout.orange.fr ([80.12.242.130]:16571 "EHLO smtp.smtpout.orange.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754777AbcILGC0 (ORCPT ); Mon, 12 Sep 2016 02:02:26 -0400 Received: from localhost.localdomain ([92.140.223.119]) by mwinf5d15 with ME id iW2K1t00a2bApm403W2L0K; Mon, 12 Sep 2016 08:02:23 +0200 X-ME-Helo: localhost.localdomain X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Mon, 12 Sep 2016 08:02:23 +0200 X-ME-IP: 92.140.223.119 From: Christophe JAILLET To: davem@davemloft.net, kuznet@ms2.inr.ac.ru, jmorris@namei.org, yoshfuji@linux-ipv6.org, kaber@trash.net Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET Subject: [PATCH] net: inet: diag: Fix an error handling Date: Mon, 12 Sep 2016 08:02:13 +0200 Message-Id: <1473660133-9195-1-git-send-email-christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.7.4 X-Antivirus: avast! (VPS 160911-2, 11/09/2016), Outbound message X-Antivirus-Status: Clean Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org If 'inet_diag_lock_handler()' returns an error, we should not call 'inet_diag_unlock_handler()' on it. 'handler' is not a valid mutexc in this case. This has been spotted with the folowing coccinelle script: //////////////////////////// @@ expression x; identifier f; @@ * if (IS_ERR(x)) { ... * f(<+... x ...+>); ... } Signed-off-by: Christophe JAILLET --- net/ipv4/inet_diag.c | 1 - 1 file changed, 1 deletion(-) diff --git a/net/ipv4/inet_diag.c b/net/ipv4/inet_diag.c index abfbe492ebfe..795af25cf84c 100644 --- a/net/ipv4/inet_diag.c +++ b/net/ipv4/inet_diag.c @@ -1134,7 +1134,6 @@ int inet_diag_handler_get_info(struct sk_buff *skb, struct sock *sk) handler = inet_diag_lock_handler(sk->sk_protocol); if (IS_ERR(handler)) { - inet_diag_unlock_handler(handler); nlmsg_cancel(skb, nlh); return PTR_ERR(handler); }