Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2432061imm; Thu, 7 Jun 2018 10:27:50 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJvuuyCcglhRqN1Ec5x1Vp9795TAR/xYgddVv9rvo4ry5EGhDvkUM+IfzV6Rz4TehKO1+sz X-Received: by 2002:a17:902:8a94:: with SMTP id p20-v6mr2944802plo.258.1528392470834; Thu, 07 Jun 2018 10:27:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528392470; cv=none; d=google.com; s=arc-20160816; b=Ynnny8HPbxld0hIOSzlJ3mn+l81npQ4o0aJCfXL+zSdsbAX0Jw+VpI3uPxnvRAyZ7F 7zuyx17fOEJd2DQW2Jc+PVXsVgmGXTsl9shVUL6MZiee9ylFRhiPabBxs4tj76GLclZ4 eCQpNM/2xKO1WTOgl5qwBnPrM2yY1W3MlwIBMUe1iEY4YCI7MTvV3lIyCrrvXlV4Cg1j Dqp3IEWkUXPOetmsxG5bFGSs1+J/1N1kYS8YXfwRPIUcPKjURwNQMrOr1glZTfvgZbox rU0mZKCYeiqWTzoo/NRI9/h1kCnW6X8efvnKL2ZhImF5VKBFAmfSWKznG4tM5gE6QgK0 xG7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition :arc-authentication-results; bh=HV5p/+VR8YFjd1Dwtad3VRG3PURrk0esSUEaajxbbWU=; b=W0G6oyYHRexZlxWkQJLk50Ulk1h5jg7NBtIgklkLMR9pXeTArgMWS2lsmlboCbAAh7 1qYL+fUymJYeYqujaHAWxX3DuCZRcyFem5F9UbzC6dviHyBRur8yLd5IoCGQvUS7PS0I C4gs9tOu0bcynlSw/GawdXOi1ay/D1nlUI9rLEj96HHgs3aM+XQXQVjsP1KjVqa3agU/ L3DSNMKkiU0LUIm6vk+uaJ9A87C0xrENTtxkARZNhReYp0vpWKU16loftDIeLqdblzjf 2W1UWG55NOEvrrUZ1aK+q2nKQG6jelZEpiEGKvtC4gIyqyV9lRBJUnPMHLuyDmEUAbVX erCQ== 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 i64-v6si26546878pli.431.2018.06.07.10.27.36; Thu, 07 Jun 2018 10:27:50 -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 S933918AbeFGOdf (ORCPT + 99 others); Thu, 7 Jun 2018 10:33:35 -0400 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:40320 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933113AbeFGOdd (ORCPT ); Thu, 7 Jun 2018 10:33:33 -0400 Received: from [148.252.241.226] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1fQvbI-0005hK-KV; Thu, 07 Jun 2018 15:09:16 +0100 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1fQvbF-0003KW-Li; Thu, 07 Jun 2018 15:09:13 +0100 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Leon Romanovsky" , "" , "Jason Gunthorpe" Date: Thu, 07 Jun 2018 15:05:21 +0100 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 408/410] RDMA/ucma: Check that device exists prior to accessing it In-Reply-To: X-SA-Exim-Connect-IP: 148.252.241.226 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.57-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Leon Romanovsky commit c8d3bcbfc5eab3f01cf373d039af725f3b488813 upstream. Ensure that device exists prior to accessing its properties. Reported-by: Fixes: 75216638572f ("RDMA/cma: Export rdma cm interface to userspace") Signed-off-by: Leon Romanovsky Signed-off-by: Jason Gunthorpe Signed-off-by: Ben Hutchings --- drivers/infiniband/core/ucma.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) --- a/drivers/infiniband/core/ucma.c +++ b/drivers/infiniband/core/ucma.c @@ -1229,7 +1229,7 @@ static ssize_t ucma_notify(struct ucma_f { struct rdma_ucm_notify cmd; struct ucma_context *ctx; - int ret; + int ret = -EINVAL; if (copy_from_user(&cmd, inbuf, sizeof(cmd))) return -EFAULT; @@ -1238,7 +1238,9 @@ static ssize_t ucma_notify(struct ucma_f if (IS_ERR(ctx)) return PTR_ERR(ctx); - ret = rdma_notify(ctx->cm_id, (enum ib_event_type) cmd.event); + if (ctx->cm_id->device) + ret = rdma_notify(ctx->cm_id, (enum ib_event_type)cmd.event); + ucma_put_ctx(ctx); return ret; }