From patchwork Mon Sep 23 09:56:36 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yongjun X-Patchwork-Id: 2927271 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 BD36B9F3C4 for ; Mon, 23 Sep 2013 09:56:44 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 66EBE202EA for ; Mon, 23 Sep 2013 09:56:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F1C2A202DD for ; Mon, 23 Sep 2013 09:56:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753447Ab3IWJ4j (ORCPT ); Mon, 23 Sep 2013 05:56:39 -0400 Received: from mail-bk0-f45.google.com ([209.85.214.45]:58898 "EHLO mail-bk0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753399Ab3IWJ4i (ORCPT ); Mon, 23 Sep 2013 05:56:38 -0400 Received: by mail-bk0-f45.google.com with SMTP id mx11so1055358bkb.4 for ; Mon, 23 Sep 2013 02:56:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:cc:content-type; bh=fViPnhB45vrexliRiw/WAbXstNIGGHT83DgCHwwv6zI=; b=xpeM92trXRwJHo6D0+tPHNyyijKrj9CDenN0z5eRhuP3DJxoP21dasXGnmI8dyWXeQ 1jRhAw9wr49BVUQk0smCk0/usZDO6GuJLyE97lfwHKhx9sRA/5y+KeoG1AlRzcwcJ3yV OnNe+K85NkWxQvaBJCa2+Jf+2knlGBHy/l5dAeP9pB7eeE2LvKhQJlnLO59JpNr1oJRv aToFpk9Yh2xageCmdzbErci/Adyi45w+sOtm2E/aHsSmuPVha68DvbHX4yHFbyuYNrH1 Z2NrbtL7Pa95WaDFs3sNrGtwqVvcWvvcjna6K5jzlf8OntM9P5TXATU0SnvW+SukaoFw gjww== MIME-Version: 1.0 X-Received: by 10.205.64.9 with SMTP id xg9mr924502bkb.30.1379930197051; Mon, 23 Sep 2013 02:56:37 -0700 (PDT) Received: by 10.205.13.74 with HTTP; Mon, 23 Sep 2013 02:56:36 -0700 (PDT) Date: Mon, 23 Sep 2013 17:56:36 +0800 Message-ID: Subject: [PATCH] NFC: nfcsim: fix the error handle in nfcsim_init() From: Wei Yongjun To: lauro.venancio@openbossa.org, aloisio.almeida@openbossa.org, sameo@linux.intel.com Cc: yongjun_wei@trendmicro.com.cn, linux-wireless@vger.kernel.org, linux-nfc@lists.01.org Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-9.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, 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: Wei Yongjun Add the missing unregister/free NFC device and destroy_workqueue() before return in the error handling case. Signed-off-by: Wei Yongjun --- drivers/nfc/nfcsim.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-wireless" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/nfc/nfcsim.c b/drivers/nfc/nfcsim.c index 9a53f13..a4a2286 100644 --- a/drivers/nfc/nfcsim.c +++ b/drivers/nfc/nfcsim.c @@ -497,15 +497,13 @@ static int __init nfcsim_init(void) dev0 = nfcsim_init_dev(); if (IS_ERR(dev0)) { rc = PTR_ERR(dev0); - goto exit; + goto exit_init_dev0; } dev1 = nfcsim_init_dev(); if (IS_ERR(dev1)) { - kfree(dev0); - rc = PTR_ERR(dev1); - goto exit; + goto exit_init_dev1; } dev0->peer_dev = dev1; @@ -513,11 +511,14 @@ static int __init nfcsim_init(void) pr_debug("NFCsim " NFCSIM_VERSION " initialized\n"); - rc = 0; + return 0; + +exit_init_dev1: + nfcsim_free_device(dev0); +exit_init_dev0: + destroy_workqueue(wq); exit: - if (rc) - pr_err("Failed to initialize nfcsim driver (%d)\n", - rc); + pr_err("Failed to initialize nfcsim driver (%d)\n", rc); return rc; }