From patchwork Mon May 12 09:17:42 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 4157501 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 6E09BBFF02 for ; Mon, 12 May 2014 09:17:48 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A783A20260 for ; Mon, 12 May 2014 09:17:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BFDD72022D for ; Mon, 12 May 2014 09:17:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755576AbaELJRo (ORCPT ); Mon, 12 May 2014 05:17:44 -0400 Received: from baptiste.telenet-ops.be ([195.130.132.51]:57697 "EHLO baptiste.telenet-ops.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752651AbaELJRm (ORCPT ); Mon, 12 May 2014 05:17:42 -0400 Received: from [192.168.1.117] ([178.119.65.67]) by baptiste.telenet-ops.be with bizsmtp id 0xHi1o0081T3uRu01xHiQD; Mon, 12 May 2014 11:17:42 +0200 Message-ID: <537091B6.5000007@acm.org> Date: Mon, 12 May 2014 11:17:42 +0200 From: Bart Van Assche User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.4.0 MIME-Version: 1.0 To: Roland Dreier CC: Alex Chiang , linux-rdma Subject: [PATCH 1/3] IB/umad: Remove container_of() != NULL tests References: <53708666.6060209@acm.org> In-Reply-To: <53708666.6060209@acm.org> X-Enigmail-Version: 1.6 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-7.5 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 container_of() never returns NULL. Hence remove the code that tests whether container_of() returns NULL. Signed-off-by: Bart Van Assche Cc: Alex Chiang Cc: --- drivers/infiniband/core/user_mad.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) - if (port) - kref_get(&port->umad_dev->ref); - else - return -ENXIO; + kref_get(&port->umad_dev->ref); if (filp->f_flags & O_NONBLOCK) { if (down_trylock(&port->sm_sem)) { diff --git a/drivers/infiniband/core/user_mad.c b/drivers/infiniband/core/user_mad.c index f0d588f..e61287c 100644 --- a/drivers/infiniband/core/user_mad.c +++ b/drivers/infiniband/core/user_mad.c @@ -783,10 +783,7 @@ static int ib_umad_open(struct inode *inode, struct file *filp) int ret; port = container_of(inode->i_cdev, struct ib_umad_port, cdev); - if (port) - kref_get(&port->umad_dev->ref); - else - return -ENXIO; + kref_get(&port->umad_dev->ref); mutex_lock(&port->file_mutex); @@ -880,10 +877,7 @@ static int ib_umad_sm_open(struct inode *inode, struct file *filp) int ret; port = container_of(inode->i_cdev, struct ib_umad_port, sm_cdev);