Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp610550yba; Sat, 13 Apr 2019 09:02:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqyn7u68FNFe9sL3/X3Wn+eqZBi23w6/VXbkrRrFu+m9F82YZYTyUCafeWHu0EzRnlOQHvvr X-Received: by 2002:a65:65c9:: with SMTP id y9mr26537485pgv.47.1555171366222; Sat, 13 Apr 2019 09:02:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555171366; cv=none; d=google.com; s=arc-20160816; b=RsOAFDsvQIks7A3URUQxwvJPRQQYzQG2HS+9XJreKkHzgD9mPkFtFcQ8C6AB68VKfL 6XO48AWLR3S2KXB2U4oGIMctfjJp95mNGlphpn9RBjmkSXjpDg3PZKZGo+NBzOVtNFBD aHE//u+gXyuO0QIW/McqOQE4O+qKZ3im9Cc1S+fqAwCcVSf/p+4AtIeMa/R+kxenoP6C fj9e0muolNGQCay0Q0G3W3Y8hOLxJIayUnu9bcSnrTsDU6tkNt1oyf4LqDUziq+weho2 FD1K1kuDR2SBidx9uopuvTm+aRVD1nl/bS5qAaallelOVAA73kSn1lmmC3d0NYAngSEg Tj9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=PfjlgJqRSuEytVVfHrZkGZOdt6+xivbCdm6BHO3PaT4=; b=juUM/E+QHexdd2flnlyftvLzht7RFhK0qXIzAVQgWwt5TJO60JlaKntGZ85taWm4V3 Zc/BmKbq6RRl7HqMclA80nYBd2OKsTE8FrwscaQVWDKya2PhomjpZ/KPDnkl45akFD9W sndS+kAtZpwtmURyrOSVPLk/8HXCScfCfy2fKDtXbnRw1WWGX/dKv7yLj/QIyHj3ISxo +AcY6BxnqUriHuu7raYrEebETPNAWMkQaxHJZg3T9SFfjfiA5PleLCzVbFheBtJdw57q uwb/hkwLWyieqpk+h/bB7LEiFZa6PuvPiyb2kVeHe7n30HGTID0zmlug9oBcWLtGG97k RXDw== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l10si40109776pgm.20.2019.04.13.09.02.30; Sat, 13 Apr 2019 09:02:46 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727282AbfDMQAd (ORCPT + 99 others); Sat, 13 Apr 2019 12:00:33 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:47564 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727191AbfDMQAc (ORCPT ); Sat, 13 Apr 2019 12:00:32 -0400 Received: from 1.general.cking.uk.vpn ([10.172.193.212] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1hFL4t-0005Wi-3W; Sat, 13 Apr 2019 16:00:27 +0000 From: Colin King To: Potnuri Bharat Teja , Doug Ledford , Jason Gunthorpe , linux-rdma@vger.kernel.org Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] RDMA/cxgb4: fix null pointer dereference on alloc_skb failure Date: Sat, 13 Apr 2019 17:00:26 +0100 Message-Id: <20190413160026.5873-1-colin.king@canonical.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Colin Ian King Currently if alloc_skb fails to allocate the skb a null skb is passed to t4_set_arp_err_handler and this ends up dereferencing the null skb. Avoid the null pointer dereference by checking for a null skb and returning early. Addresses-Coverity: ("Dereference null return") Fixes: b38a0ad8ec11 ("RDMA/cxgb4: Set arp error handler for PASS_ACCEPT_RPL messages") Signed-off-by: Colin Ian King --- drivers/infiniband/hw/cxgb4/cm.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/infiniband/hw/cxgb4/cm.c b/drivers/infiniband/hw/cxgb4/cm.c index 1e68d87b663d..0f3b1193d5f8 100644 --- a/drivers/infiniband/hw/cxgb4/cm.c +++ b/drivers/infiniband/hw/cxgb4/cm.c @@ -460,6 +460,8 @@ static struct sk_buff *get_skb(struct sk_buff *skb, int len, gfp_t gfp) skb_reset_transport_header(skb); } else { skb = alloc_skb(len, gfp); + if (!skb) + return NULL; } t4_set_arp_err_handler(skb, NULL, NULL); return skb; -- 2.20.1