Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1152309imm; Wed, 1 Aug 2018 11:03:09 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdew9a412HPQ4kX5IGlGws3FQwDYmDEp0JQsOFbvoxx8ngAHUbxouOP78ODfx9OylCpIJoL X-Received: by 2002:a17:902:20c2:: with SMTP id v2-v6mr26069963plg.22.1533146589100; Wed, 01 Aug 2018 11:03:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533146589; cv=none; d=google.com; s=arc-20160816; b=ZCPtGIOWa9U1KQEbFTJdoCA5vLeN/qQvyx7MYR6Ytr6zPeVUuf119E96SKRbrDa8WE h1jAq3PumGMeV+EchMZXdcPmTCeePwxrEI54ISNbIPh6nb/q9/+VtZRI5uDnNkzPmaNA urS8dLccAktReHzVRN58IGOOOWrJi8iVFfEhSGxh5FLkAjjOX/8K54Cw4QZS1mbm6pi/ SrlhyvoeZHLmq4yx6wrXdlSknJCupJ0VBxUP5Jp/shmCRosbOCGHDgTUkdYH3Q9bzQ3K M471TH/6fDMb0QU8W3ZIZExaoS1LwEY2D0OtyW9qUBD9aeTBtGxFX4mN2l9RvYpcDuSr SKFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=xUIy3tsl+QVfMtiwvB8R62apkJq+AsWAAK5nOBISwiA=; b=OA0+UX5M7IzbrXPydKMx70XgzppnnhpyCDTEjqQP2s5upyK3LbgOVt2wASAb+Nifqg eK+dddg43axMSUApGA9ANp5HEytT70pIZtDsbSQnR7qcX9PEpU9ivdkOY67Ti9iYA7SS XFFOlebABv2B9aUUcJOAzq7rLZYZrNgD5T1m32RKi1Qb+qUJbCIih65uzT4FJ5DkJber JcXmV9+w0i5Yd4d/B8lEZDe99tGMABnNJ9tXqLQr/9cVnmql7jlO+EIdiIDYqV9Of0RA 5QXlchVY8QGKPWGaB8E4PuXDzrbr50N2cYpy6YONzgXJ0DB7l3LPx4FjxWJgK7VmCeQG XIfQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a18-v6si16387337plm.122.2018.08.01.11.02.54; Wed, 01 Aug 2018 11:03:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732533AbeHATsw (ORCPT + 99 others); Wed, 1 Aug 2018 15:48:52 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:50270 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405877AbeHATIi (ORCPT ); Wed, 1 Aug 2018 15:08:38 -0400 Received: from localhost (D57E6652.static.ziggozakelijk.nl [213.126.102.82]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id F0DB81381; Wed, 1 Aug 2018 17:14:25 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Leon Romanovsky , Doug Ledford , Sasha Levin Subject: [PATCH 4.14 051/246] RDMA/mad: Convert BUG_ONs to error flows Date: Wed, 1 Aug 2018 18:49:21 +0200 Message-Id: <20180801165014.160207963@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180801165011.700991984@linuxfoundation.org> References: <20180801165011.700991984@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Leon Romanovsky [ Upstream commit 2468b82d69e3a53d024f28d79ba0fdb8bf43dfbf ] Let's perform checks in-place instead of BUG_ONs. Signed-off-by: Leon Romanovsky Signed-off-by: Doug Ledford Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/infiniband/core/mad.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) --- a/drivers/infiniband/core/mad.c +++ b/drivers/infiniband/core/mad.c @@ -1558,7 +1558,8 @@ static int add_oui_reg_req(struct ib_mad mad_reg_req->oui, 3)) { method = &(*vendor_table)->vendor_class[ vclass]->method_table[i]; - BUG_ON(!*method); + if (!*method) + goto error3; goto check_in_use; } } @@ -1568,10 +1569,12 @@ static int add_oui_reg_req(struct ib_mad vclass]->oui[i])) { method = &(*vendor_table)->vendor_class[ vclass]->method_table[i]; - BUG_ON(*method); /* Allocate method table for this OUI */ - if ((ret = allocate_method_table(method))) - goto error3; + if (!*method) { + ret = allocate_method_table(method); + if (ret) + goto error3; + } memcpy((*vendor_table)->vendor_class[vclass]->oui[i], mad_reg_req->oui, 3); goto check_in_use;