Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1064628ybl; Wed, 14 Aug 2019 10:08:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqxGzIvFdYBArpka4HWrnCYc8Bx+3N3/3nufmDUZiQngcCI4Ih/vgtswe/cKNM9jiTpmNBC6 X-Received: by 2002:a63:f941:: with SMTP id q1mr191640pgk.350.1565802503040; Wed, 14 Aug 2019 10:08:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565802503; cv=none; d=google.com; s=arc-20160816; b=sxCdhiq7jdqIGauTNFr9OVHR8jwHw2Zvn/oSxRfMBdbXdi99EKs+zLNDzHlykTE95B i4oWKooKOb3pUHjh3Ar1YRCwO/CmEtCDREz+rhSx34JjEdeedwX1bR/Vgd9UnUPW83F0 xUAuli+T0MfQIyVfEXo5RaIH6WybADzW5NZ5S5UG+C9NH4JzrrCqGyPNUc4m27DKjG/d 1bKk89renbw8lsy6ojfcfhm/0G/rFpAQOOGzYN1fyR443e3eESrmDSa8BQYlF2+3B2rI A+M3DUcwZgUo4CQsLqHfGDfPxH6H6PoOYQ8S4rZz18oPuFz4b5ZzdR8O/vuxmJFGN804 hPIg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=2s0rw4GhuzAniN0UXVwUUiW8kLhkwJvd2DFd/OTZeOk=; b=poPuUrctb8LYr96qsL4HxX/a4wqHvei33UUWXlNxgM9lsH7rJ5CMLWdr5q4eyueBvu xFpYT/4/xnvf3YiGL7BRuPXimfXchP7KOuO2rBq35FDvE16DuL48QTxuTU1PREGWuMr0 te/REsCm9fArPvSgexo8v2bh0ss9yPkE77bBPWPBdaR1S/3cMvSfd1SAqvPPZZQMO/lU X9oSsq9CzqMpNwGa2TxO6XBS5Li4eCZPPAl5j3KTWNU3jG6r/Q8h3UyIDb/YTkfRXsYl 4oBRBkfo/SZXo+BAhzv1G7YAd+0eYahwz79aXvaRrcuF3KFt1d9L67Qcj2gTaHFgp5vw 8qng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=CrXMQCjn; 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 a1si79212pff.73.2019.08.14.10.08.06; Wed, 14 Aug 2019 10:08:23 -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; dkim=pass header.i=@kernel.org header.s=default header.b=CrXMQCjn; 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 S1729415AbfHNRFW (ORCPT + 99 others); Wed, 14 Aug 2019 13:05:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:54188 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729401AbfHNRFR (ORCPT ); Wed, 14 Aug 2019 13:05:17 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D68802084D; Wed, 14 Aug 2019 17:05:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565802317; bh=opFJpgTClBgfG8Nm64vOfdsYXzGQOp9y9phS/LKcW+c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CrXMQCjnk3lwLIhBDYKeiqOlMV71DIHM7DyufgU9Kd70+vpY75bpUpbFlJd+H9Mad o8babhXR2Sg0xnV7wrr2wg4zCufuppcc2AujUMU4fqR3u9CEDsIMU9nFVG3sqwhxRk Pd6e8RUICPJHJ5URbWEOUcJV53EGzlbJzYiLgFSU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Navid Emamdoost , "David S. Miller" , Sasha Levin Subject: [PATCH 5.2 078/144] allocate_flower_entry: should check for null deref Date: Wed, 14 Aug 2019 19:00:34 +0200 Message-Id: <20190814165803.118010522@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190814165759.466811854@linuxfoundation.org> References: <20190814165759.466811854@linuxfoundation.org> User-Agent: quilt/0.66 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 [ Upstream commit bb1320834b8a80c6ac2697ab418d066981ea08ba ] allocate_flower_entry does not check for allocation success, but tries to deref the result. I only moved the spin_lock under null check, because the caller is checking allocation's status at line 652. Signed-off-by: Navid Emamdoost Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.c index cfaf8f618d1f3..56742fa0c1af6 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.c +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.c @@ -67,7 +67,8 @@ static struct ch_tc_pedit_fields pedits[] = { static struct ch_tc_flower_entry *allocate_flower_entry(void) { struct ch_tc_flower_entry *new = kzalloc(sizeof(*new), GFP_KERNEL); - spin_lock_init(&new->lock); + if (new) + spin_lock_init(&new->lock); return new; } -- 2.20.1