Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp5334732img; Wed, 27 Mar 2019 06:42:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqxiUrpgzM1sM3af1z/Iw7VwnCdYHGyAlvzAj7Rit6CxRQV6CZXecUpe7byRMnQPf9iat2hz X-Received: by 2002:a17:902:7590:: with SMTP id j16mr2520078pll.98.1553694135694; Wed, 27 Mar 2019 06:42:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553694135; cv=none; d=google.com; s=arc-20160816; b=DI7k2KPjTZ0mr7M0qWa8993SZ+NyyMlr815BMlNqNw4txlFigYdSnUSkpz9/vdgrqf p0cs9z+smGPcZpOhlqZEwqQVORPHFWLXaxDhc+Q25m8GpmFHvPZ4cLpArbCqo2DjNPBR j9Gqty6al39GEgbqUocFmVg9eFCPH/XvGlRbmyig4OM37yybNSAijc9z6yCpk5J29kv7 wNVsAjzxPnJmfTMWEpCcPCd/7+Yn70IwZ+sBN/lVsobLetoheEK7A2XC0V1fA9MHogv8 nhERu+NePLu4PkB5F4hFdFvUMt067QRtwol9K77VeCJkc5yN85RYo7MhpuMujHVbOsdZ HKTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=tNQU+0zr0zaW56WEqVI8uZFh8YnispH8Xhwcy6fTc/A=; b=SQyWUvdnrNdMKf1wxskMNwQTkLsRYFeEL+zcRyEwF0SkiG0tyn4PAifJYDgUc3TjUY 4SDwIvhsPo/OviC9PMv0LCJgDuUd4CYuDXUyalI+g+hJMJzOq14A8JPEJhud+P6HBHQn sy5GOSi5zSO26tXrrRuBUn+Gp7slxrBNp/otpiyRpAkolN80fRu24v4b+a2og5p2ZFcw I1BUScoLOnP7kikaxf59db+dML5YfFoX4AzzV1q0X9U+Ch2HZ5zqlqerk8QdnhZ3wM/S rqbNi88PRSsreZw0E+0eNW4rYasUQfFYDpHz++FsUeSXtmXDBpsIQCr9OkZODvIfwKAs B6Qg== 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 y11si18878230plk.323.2019.03.27.06.41.58; Wed, 27 Mar 2019 06:42:15 -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 S1729385AbfC0Nj6 (ORCPT + 99 others); Wed, 27 Mar 2019 09:39:58 -0400 Received: from stargate.chelsio.com ([12.32.117.8]:34294 "EHLO stargate.chelsio.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728383AbfC0Nj6 (ORCPT ); Wed, 27 Mar 2019 09:39:58 -0400 Received: from localhost (mehrangarh.blr.asicdesigners.com [10.193.185.169]) by stargate.chelsio.com (8.13.8/8.13.8) with ESMTP id x2RDctrM026024; Wed, 27 Mar 2019 06:38:55 -0700 Date: Wed, 27 Mar 2019 19:08:54 +0530 From: Potnuri Bharat Teja To: Kangjie Lu Cc: "pakki001@umn.edu" , Doug Ledford , Jason Gunthorpe , "linux-rdma@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH] infiniband: cxgb4: fix a potential NULL pointer dereference Message-ID: <20190327133728.GA26660@chelsio.com> References: <20190309051921.15212-1-kjlu@umn.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Saturday, March 03/23/19, 2019 at 08:07:46 +0530, Kangjie Lu wrote: > > > > On Mar 8, 2019, at 11:19 PM, Kangjie Lu wrote: > > > > get_skb may fail and return NULL. The fix returns "ENOMEM" > > when it fails to avoid NULL dereference. > > > > Signed-off-by: Kangjie Lu > > --- > > drivers/infiniband/hw/cxgb4/cm.c | 3 +++ > > 1 file changed, 3 insertions(+) > > > > diff --git a/drivers/infiniband/hw/cxgb4/cm.c b/drivers/infiniband/hw/cxgb4/cm.c > > index 8221813219e5..502a54d57e2c 100644 > > --- a/drivers/infiniband/hw/cxgb4/cm.c > > +++ b/drivers/infiniband/hw/cxgb4/cm.c > > @@ -1919,6 +1919,9 @@ static int send_fw_act_open_req(struct c4iw_ep *ep, unsigned int atid) > > int win; > > > > skb = get_skb(NULL, sizeof(*req), GFP_KERNEL); > > + if (!skb) > > + return -ENOMEM; > > + > > Can someone review this patch? Thanks. Sorry for the late response. I recommend an error print before the return. --- if (!skb) { pr_err("%s - failed to alloc skb\n", __func__); return -ENOMEM; } --- Thanks for the patch! - Bharat. > > > req = __skb_put_zero(skb, sizeof(*req)); > > req->op_compl = htonl(WR_OP_V(FW_OFLD_CONNECTION_WR)); > > req->len16_pkd = htonl(FW_WR_LEN16_V(DIV_ROUND_UP(sizeof(*req), 16))); > > -- > > 2.17.1 > > >