From patchwork Wed Jun 26 15:07:16 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "John W. Linville" X-Patchwork-Id: 2786301 Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 9A9499F245 for ; Wed, 26 Jun 2013 15:15:31 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 006062046B for ; Wed, 26 Jun 2013 15:15:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B680B204A2 for ; Wed, 26 Jun 2013 15:15:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751646Ab3FZPPO (ORCPT ); Wed, 26 Jun 2013 11:15:14 -0400 Received: from charlotte.tuxdriver.com ([70.61.120.58]:41138 "EHLO smtp.tuxdriver.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751581Ab3FZPPM (ORCPT ); Wed, 26 Jun 2013 11:15:12 -0400 Received: from uucp by smtp.tuxdriver.com with local-rmail (Exim 4.63) (envelope-from ) id 1UrrR9-0007Hd-7A; Wed, 26 Jun 2013 11:15:11 -0400 Received: from linville-x1.hq.tuxdriver.com (localhost.localdomain [127.0.0.1]) by linville-x1.hq.tuxdriver.com (8.14.7/8.14.6) with ESMTP id r5QF7Lhl007005; Wed, 26 Jun 2013 11:07:22 -0400 Received: (from linville@localhost) by linville-x1.hq.tuxdriver.com (8.14.7/8.14.7/Submit) id r5QF7LKL007004; Wed, 26 Jun 2013 11:07:21 -0400 From: "John W. Linville" To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, "John W. Linville" Subject: [PATCH] iw: reorder some code in iw_connect to avoid a potential memory leak Date: Wed, 26 Jun 2013 11:07:16 -0400 Message-Id: <1372259236-6968-1-git-send-email-linville@tuxdriver.com> X-Mailer: git-send-email 1.8.1.4 MIME-Version: 1.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-8.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: "John W. Linville" From Coverity run on version 3.10: iw-3.10/connect.c:104:leaked_storage – Variable "conn_argv" going out of scope leaks the storage it points to. Signed-off-by: John W. Linville --- connect.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/connect.c b/connect.c index 74e4578..fb3b2fe 100644 --- a/connect.c +++ b/connect.c @@ -94,15 +94,15 @@ static int iw_connect(struct nl80211_state *state, struct nl_cb *cb, argv++; } + err = __prepare_listen_events(state); + if (err) + return err; + conn_argc = 3 + argc; conn_argv = calloc(conn_argc, sizeof(*conn_argv)); if (!conn_argv) return -ENOMEM; - err = __prepare_listen_events(state); - if (err) - return err; - conn_argv[0] = dev; conn_argv[1] = "connect"; conn_argv[2] = "establish";