From patchwork Tue Jan 9 09:27:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 10151297 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id CE909603ED for ; Tue, 9 Jan 2018 09:32:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CC64B28429 for ; Tue, 9 Jan 2018 09:32:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C049626538; Tue, 9 Jan 2018 09:32:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6D4D526538 for ; Tue, 9 Jan 2018 09:32:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752509AbeAIJcc (ORCPT ); Tue, 9 Jan 2018 04:32:32 -0500 Received: from aserp2120.oracle.com ([141.146.126.78]:50810 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752365AbeAIJcb (ORCPT ); Tue, 9 Jan 2018 04:32:31 -0500 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.22/8.16.0.21) with SMTP id w099VuOk127779; Tue, 9 Jan 2018 09:32:25 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : mime-version : content-type; s=corp-2017-10-26; bh=goBFRlkESz0skxD5JpYZ1+06Wrcnm6PBVpqQQQgM1g4=; b=rD1I+y4Ichu/P2raFfnfSj1ksqxk+ZwkbjUhVuCUxKyme0Rf+McBEMOVAtHduqmORL4L Y0v2YRinoNFlhuUI7jnXCzd+wDwJH06fZDufr8jSV1BA3tm5+iDIHg6S8dnCrctnHIZc 6pgfiozgC5cmPJDozLTBkc2ZF6h8qbzvVIHEGJjnqbGLtZeUNJTqUZew+NX8TdIw1vnf gxYaN4WsiCa38DLFFTEwBCo7mrLZmlQJ7zBjiF8QQnlVSgBYlVhmbHAaZANK9i2ZVxB3 r19XVOOXWepEB0Yoi/zMLFll9fJ46pkhabJBdaeJ97Eskm1ZQR0/7nfFZOTcyk6ayBKh IQ== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp2120.oracle.com with ESMTP id 2fcsj18bv9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 09 Jan 2018 09:32:25 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w099ROIw020965 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 9 Jan 2018 09:27:25 GMT Received: from abhmp0004.oracle.com (abhmp0004.oracle.com [141.146.116.10]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w099RNjI011596; Tue, 9 Jan 2018 09:27:23 GMT Received: from mwanda (/197.157.34.162) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 09 Jan 2018 01:27:22 -0800 Date: Tue, 9 Jan 2018 12:27:14 +0300 From: Dan Carpenter To: Mike Marciniszyn , "Michael J. Ruhl" Cc: Dennis Dalessandro , Doug Ledford , Jason Gunthorpe , linux-rdma@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH] IB/hfi1: Prevent a NULL dereference Message-ID: <20180109092714.valolokywtmbprw7@mwanda> MIME-Version: 1.0 Content-Disposition: inline X-Mailer: git-send-email haha only kidding User-Agent: NeoMutt/20170609 (1.8.3) X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8768 signatures=668652 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=502 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1801090134 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In the original code, we set "fd->uctxt" to NULL and then dereference it which will cause an Oops. Fixes: f2a3bc00a03c ("IB/hfi1: Protect context array set/clear with spinlock") Signed-off-by: Dan Carpenter Acked-by: Dennis Dalessandro --- 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/hw/hfi1/file_ops.c b/drivers/infiniband/hw/hfi1/file_ops.c index 82086241aac3..3de1ac94bb85 100644 --- a/drivers/infiniband/hw/hfi1/file_ops.c +++ b/drivers/infiniband/hw/hfi1/file_ops.c @@ -763,10 +763,10 @@ static int complete_subctxt(struct hfi1_filedata *fd) } if (ret) { + __clear_bit(fd->subctxt, fd->uctxt->in_use_ctxts); hfi1_rcd_put(fd->uctxt); fd->uctxt = NULL; spin_lock_irqsave(&fd->dd->uctxt_lock, flags); - __clear_bit(fd->subctxt, fd->uctxt->in_use_ctxts); spin_unlock_irqrestore(&fd->dd->uctxt_lock, flags); }