From patchwork Fri Jun 21 03:24:27 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yongjun X-Patchwork-Id: 2760051 Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 06EA6C0AB1 for ; Fri, 21 Jun 2013 03:24:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id ECA8B2019E for ; Fri, 21 Jun 2013 03:24:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 10E5E201A5 for ; Fri, 21 Jun 2013 03:24:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1030408Ab3FUDY3 (ORCPT ); Thu, 20 Jun 2013 23:24:29 -0400 Received: from mail-we0-f170.google.com ([74.125.82.170]:48781 "EHLO mail-we0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030403Ab3FUDY2 (ORCPT ); Thu, 20 Jun 2013 23:24:28 -0400 Received: by mail-we0-f170.google.com with SMTP id w57so6104494wes.29 for ; Thu, 20 Jun 2013 20:24:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=CniQKgb/BaO2ysKLUL8upcrehMNr7738bM5SeweRSHI=; b=txPAc9srmIv/WIUCuay63SA31danJSXaMeYEOiKdTSsV6g7Okofip/nTDW9mwPWGrT Ayj5xUbGvrBiUEQMlEvCOPN3zGXh3c97jg4WzWlPrKh9kYjkEhDvnLfns2LFEyJYulfz pld0jS2o46LtggimA9K4mGwVUH26YOJV4pamflFKqLk3EZOcLhyvfi3EnuxUL/spKffS LCy52KRBq6PIr5839Tr8FQkPlK9y62NOIDhzcdmmh7AUGU9X26YE7WZE/5QHP7YffNHl P/Os7ekQZ3uRyHK6+euSZed26I91QY6I29DCZo2mg/ZMOyEan/ynSocA81AsogpjkrPP WLBQ== MIME-Version: 1.0 X-Received: by 10.194.48.49 with SMTP id i17mr7870195wjn.55.1371785067518; Thu, 20 Jun 2013 20:24:27 -0700 (PDT) Received: by 10.194.240.167 with HTTP; Thu, 20 Jun 2013 20:24:27 -0700 (PDT) In-Reply-To: <1828884A29C6694DAF28B7E6B8A823736FD35AD4@ORSMSX109.amr.corp.intel.com> References: <1828884A29C6694DAF28B7E6B8A823736FD35AD4@ORSMSX109.amr.corp.intel.com> Date: Fri, 21 Jun 2013 11:24:27 +0800 Message-ID: Subject: [PATCH v2] IB/core: Fix error return code in add_port() From: Wei Yongjun To: sean.hefty@intel.com Cc: roland@kernel.org, hal.rosenstock@gmail.com, yongjun_wei@trendmicro.com.cn, linux-rdma@vger.kernel.org Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-8.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=unavailable 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 Fix to return -ENOMEM in the add_port() error handling case instead of 0, as done elsewhere in this function. Signed-off-by: Wei Yongjun --- v1 -> v2: change patch description --- drivers/infiniband/core/sysfs.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" 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/infiniband/core/sysfs.c b/drivers/infiniband/core/sysfs.c index 246fdc1..d9b78c4 100644 --- a/drivers/infiniband/core/sysfs.c +++ b/drivers/infiniband/core/sysfs.c @@ -545,8 +545,10 @@ static int add_port(struct ib_device *device, int port_num, p->gid_group.name = "gids"; p->gid_group.attrs = alloc_group_attrs(show_port_gid, attr.gid_tbl_len); - if (!p->gid_group.attrs) + if (!p->gid_group.attrs) { + ret = -ENOMEM; goto err_remove_pma; + } ret = sysfs_create_group(&p->kobj, &p->gid_group); if (ret) @@ -555,8 +557,10 @@ static int add_port(struct ib_device *device, int port_num, p->pkey_group.name = "pkeys"; p->pkey_group.attrs = alloc_group_attrs(show_port_pkey, attr.pkey_tbl_len); - if (!p->pkey_group.attrs) + if (!p->pkey_group.attrs) { + ret = -ENOMEM; goto err_remove_gid; + } ret = sysfs_create_group(&p->kobj, &p->pkey_group); if (ret)