From patchwork Mon May 12 08:30:23 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: 4157851 Return-Path: X-Original-To: patchwork-linux-rdma@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 907A99F170 for ; Mon, 12 May 2014 09:37:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B7B89201C0 for ; Mon, 12 May 2014 09:37:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DB0C82022A for ; Mon, 12 May 2014 09:37:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751428AbaELJhc (ORCPT ); Mon, 12 May 2014 05:37:32 -0400 Received: from sf2.bxl.stone.is ([5.134.1.239]:39213 "EHLO sf2.bxl.stone.is" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750892AbaELJhb (ORCPT ); Mon, 12 May 2014 05:37:31 -0400 X-Greylist: delayed 2358 seconds by postgrey-1.27 at vger.kernel.org; Mon, 12 May 2014 05:37:31 EDT Received: from smtp03.stone-is.org ([87.238.162.6] helo=smtpgw.stone-is.be) by sf2.bxl.stone.is with esmtp (Exim 4.82) (envelope-from ) id 1Wjm3k-0007BN-5r; Mon, 12 May 2014 10:58:10 +0200 Received: from localhost (unknown [127.0.0.1]) by smtpgw.stone-is.be (Postfix) with ESMTP id 34FC8334CA3; Mon, 12 May 2014 08:30:26 +0000 (UTC) Received: from smtpgw.stone-is.be ([127.0.0.1]) by localhost (smtpgw.stone-is.be [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id wp56OgU7kSji; Mon, 12 May 2014 10:30:24 +0200 (CEST) Received: from vz19.stone-is.net (vz19.stone-is.net [87.238.162.57]) by smtpgw.stone-is.be (Postfix) with ESMTP id 678A5334BBB; Mon, 12 May 2014 10:30:24 +0200 (CEST) X-No-Relay: not in my network X-No-Relay: not in my network X-No-Relay: not in my network Received: from [192.168.1.117] (178-119-65-67.access.telenet.be [178.119.65.67]) by vz19.stone-is.net (Postfix) with ESMTPSA id 181A388D6A; Mon, 12 May 2014 10:30:24 +0200 (CEST) Message-ID: <5370869F.5040103@acm.org> Date: Mon, 12 May 2014 10:30:23 +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 X-Filter-ID: XtLePq6GTMn8G68F0EmQvdthj6rk7ohlAkaRQG+cDaLZlN3ufQ0ZRHdy43341LQ0JYRGiu4wDuX/ sGw1Y7RAsb1SR70Wkof6QMErSa5awdkG42j8At+vc1CnB5mb3BSJepitAFwwEbMGYUpxADAT6yBk 0ydfoHV3ZNUPsk+Z52roCkoJ9G4OvGb2HIs11FkfMlUS0dQK1WpVL+8woncDCFZyJUEcMvG4mvmE 6ju34Rtpul1GZqDYUymLu12OdAVvZuM7jUXIESohoO51xWmU8RJAVQYcOmAyRxcS32YydgD3I84v mkP3oh+YQqB4J59UsV2kVJ6iI4C9lEspssReek9NT0wnz2h8ADwycfME7g7Q08vWrPDgMXSp0PD/ +0YjOyzxI2kbjN9NHAai2rh92SivUpI7xYBewOHb5FYgdqqjrcITHcksS7joBcHFiJvPoXKxVxxs Ub1NautSP08O+Rz9D+/9oSt5jUrIaWXjdPREcrtd1OJc8clu1cTxQ0e5UzNQey813JRaAeaBSS7l 0j3WJzM9TQ2QEdWAURl0Sg657IUNtZsmYlZe2TrEPH/IRxp/ML3veOwhSb18HyQeGw6LUO0JT1q/ AWrYG3aFTnrgE00jGSWzc/YN/cq8gbcPksXEBiUIXWNB+wX14uxazRfBC1MKWcjGYXE+LFtYG0YJ nS1qNPfCzFo6p4c3bTR5 X-Report-Abuse-To: spam@sf1.bxl.stone.is X-Originating-IP: 87.238.162.6 X-SpamExperts-Domain: stone.is X-SpamExperts-Username: 87.238.162.6 Authentication-Results: bxl.stone.is; auth=pass smtp.auth=87.238.162.6 X-SpamExperts-Outgoing-Class: ham X-SpamExperts-Outgoing-Evidence: Combined (0.03) X-Recommended-Action: accept 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(-) 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); - 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)) {