From patchwork Fri Jun 30 05:46:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Pundir X-Patchwork-Id: 106672 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1904897qge; Thu, 29 Jun 2017 22:47:38 -0700 (PDT) X-Received: by 10.98.103.18 with SMTP id b18mr20425748pfc.171.1498801658334; Thu, 29 Jun 2017 22:47:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498801658; cv=none; d=google.com; s=arc-20160816; b=pfJ3p6HRJC7vSRdgpj30qeOwEVodlfJW/J82B/0KzRGmZtRFfIF7WcqYHkhigzEjdh m2BHhuq5kT9YcGttv98A0gA/hCQb6HAqsT4sEx8mKBjK9P01Vqh9oMrtZynWmuKkSpiX HlY49ba++mUuNdnbH5nmeJncIpuCcepeIaRSK7Du1unm+nBVuDQ/eyayYlOjpFYO640A bflr78BPHlC5ZEi09JteGbvU70qAFMRivy55uG5KOCMw67WuHNz35vXNwQ8pQIMKJz// f6h/jz07gasU3lO8qpxJ4accFKh76LcidrAHPqyOGrDJPDHA7r2cWqKgVuz0Zhqsjavl nrSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=GsegNdTqjU2IqSIX6ahbN1smnKBB+hrS5MXnKypGrvw=; b=ycJoA1SArQiKqqkrDg6Hab0J7dGc90b7vPmS81Ckk70XUwJ+X3n9C4YVQcasUQPF0A 7D2yxOKEVYPJyMURqILNOnpv3UFYr95q+iKxi8rbpYbNLAwcmsgHOayZ6Bbx/dyH61KK edCXHGrYwCKNAyp462l5FYhPEwEm/o/J+k+J3zN89Yu2fcWUgq/IcdCtWoets+A2bvWN 8EY9+RokgyJ2aE1JIW815ulQEAnmcn+KBUXZ6YaZehOFMrI8oJb59mk2rNSU3WCVgi9u iIf1knJD/pIFiEE1idrHFp8MjRrBcnOTCXonCiI/ksm5uu+xP36J8LvBENXz8ykJpICY 0ujQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.b=fu4SnNJK; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m5si4519277pgj.463.2017.06.29.22.47.38; Thu, 29 Jun 2017 22:47:38 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.b=fu4SnNJK; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752086AbdF3Frg (ORCPT + 6 others); Fri, 30 Jun 2017 01:47:36 -0400 Received: from mail-pg0-f43.google.com ([74.125.83.43]:34184 "EHLO mail-pg0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752071AbdF3Fre (ORCPT ); Fri, 30 Jun 2017 01:47:34 -0400 Received: by mail-pg0-f43.google.com with SMTP id t186so58776128pgb.1 for ; Thu, 29 Jun 2017 22:47:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=GsegNdTqjU2IqSIX6ahbN1smnKBB+hrS5MXnKypGrvw=; b=fu4SnNJKCZpfBLJDBHtNL5ueDEwPwZiHbrRh07lRvY7fejIZsIKI5K1RpVQRp/P+nh feMmKVNAuql62viiCBUWJmbQ2GJROkIiDm54jFV+pGBWWDxR9BNT2POZCEo5z1uJ3rCg xE4oDWuU055JudtU384C/PKXhcfMJNjNwxFOo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=GsegNdTqjU2IqSIX6ahbN1smnKBB+hrS5MXnKypGrvw=; b=mIbwfel7qHak9R43PzDiw4Aw2ef1cOTJ/coAhGec3ZnzjDdJRd2ZucixAXfzx2WbfN zCymiXiuGPNa6gOK+aTAF46J8K6dhMbsZPUKNrdtZCvy5+Q12xht+6k8EWLTzWL0YxmV tgAW3mJLf4hCVHP4MI8ds4fejgO9JtkTowZJta8q9toR3osMuq6LiBhhQxJwOrI7npm/ 8nHJDAr/ADuthPkXXMyqMCv2vY8LQ70HAWop5S2YdSDfcvMAgWvLXjl2v8T6mINo7vlW +BBx9e+r/r2bpna6R+1kOTLQwbRadDt2SjF53YuxQdYKLuKsfIqU/MhLBODaNFbf0P3C WY2w== X-Gm-Message-State: AKS2vOz42uE4P9HUg2PKt47Ap7Hu/tyrKiOO+V2RBlhpbHXnDrc9/RAf Rgh0inSqTQpwjzVkQebb/w== X-Received: by 10.98.9.205 with SMTP id 74mr20185009pfj.77.1498801643415; Thu, 29 Jun 2017 22:47:23 -0700 (PDT) Received: from localhost.localdomain ([106.51.129.233]) by smtp.gmail.com with ESMTPSA id a187sm11405550pgc.37.2017.06.29.22.47.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 29 Jun 2017 22:47:22 -0700 (PDT) From: Amit Pundir To: Greg KH Cc: Stable , wangweidong , "David S . Miller" Subject: [PATCH for-4.4 12/16] bgmac: fix a missing check for build_skb Date: Fri, 30 Jun 2017 11:16:36 +0530 Message-Id: <1498801600-20896-13-git-send-email-amit.pundir@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1498801600-20896-1-git-send-email-amit.pundir@linaro.org> References: <1498801600-20896-1-git-send-email-amit.pundir@linaro.org> Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: wangweidong commit f1640c3ddeec12804bc9a21feee85fc15aca95f6 upstream. when build_skb failed, it may occure a NULL pointer. So add a 'NULL check' for it. Signed-off-by: Weidong Wang Signed-off-by: David S. Miller Signed-off-by: Amit Pundir --- drivers/net/ethernet/broadcom/bgmac.c | 5 +++++ 1 file changed, 5 insertions(+) -- 2.7.4 diff --git a/drivers/net/ethernet/broadcom/bgmac.c b/drivers/net/ethernet/broadcom/bgmac.c index b56c9c581359..b7e10e1b9131 100644 --- a/drivers/net/ethernet/broadcom/bgmac.c +++ b/drivers/net/ethernet/broadcom/bgmac.c @@ -469,6 +469,11 @@ static int bgmac_dma_rx_read(struct bgmac *bgmac, struct bgmac_dma_ring *ring, len -= ETH_FCS_LEN; skb = build_skb(buf, BGMAC_RX_ALLOC_SIZE); + if (unlikely(skb)) { + bgmac_err(bgmac, "build_skb failed\n"); + put_page(virt_to_head_page(buf)); + break; + } skb_put(skb, BGMAC_RX_FRAME_OFFSET + BGMAC_RX_BUF_OFFSET + len); skb_pull(skb, BGMAC_RX_FRAME_OFFSET +