Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1069593ybl; Wed, 14 Aug 2019 10:12:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqzdYtG3CjVqFC/AE5hvJZyg8Zaz8X6Ra6dblN0ZXdnQQBcdMEOpRFC1mddkOYDW49q2HLKe X-Received: by 2002:a63:6904:: with SMTP id e4mr168284pgc.321.1565802744374; Wed, 14 Aug 2019 10:12:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565802744; cv=none; d=google.com; s=arc-20160816; b=Rz4VwefANfakKwq+UR4564wrNrLaFTlWjyaD0VOVi1HiQ3cQKgHZQIRybC0TyYUUml PuGjM0K1b4MdI75PIA00hmHDY2kEDFZE4rV3vsXpISOsCUeKuYNJlyLJdW41oXWObGqp eoDyO8j7s1WnVRvo/W0hriSnwF1JeVtx5hh92JGakMK2dijg4yA8jXi3LuQ/EIWs79NZ V3Lf1Z8N9uOTguOjvKf6JXZttBEmXCpwZjYpeQ2PagNCUq1l1unzVzlaGuWwBB1dWo/Z Cd6amRH7cG2gE/mabTbZGJWZmBWPML12/oiZhAkCLprt3tWCqGenahOrT/pUvY/bWMos BthA== 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=tE9fXYgcu3qkYHucq2jRBKrusT6/Q4lg9P0ejHum1aQ=; b=frVjdyDNv21hCAOa6B3om2zGxR3xws1Pa4of7JDNSuywOJ72NA5/Bq/VB2YhHAxuVN A+RwSC7G7nfpqqOUgUmuk6NMx8icpPUm0/UFClWkMOK44fI3B6YplgxxOizMhhZ8a6G5 SpdadxuzWvIKdtn0OZg7APOVJ8GOfFH38cQxG3FGlA/rdzZrxcVMy5SLbIdT1d3A8V3D BLJJ9cfnj2rBiJDXa2gDDFph5NbK0ZVNz5wIbNsacj5ulbCdM+45sGvsc7I08Fb3umJT C4+zYpeLGuoUe3P3HH5r3/4Wq5zbfndCr+42VsQ+M9afSDtuvdbL1tTaRwWw7GHvNL2V 8ZWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=s7rv3BGb; 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 131si171469pgf.597.2019.08.14.10.12.08; Wed, 14 Aug 2019 10:12:24 -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=s7rv3BGb; 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 S1729303AbfHNRKN (ORCPT + 99 others); Wed, 14 Aug 2019 13:10:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:60810 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730099AbfHNRKG (ORCPT ); Wed, 14 Aug 2019 13:10:06 -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 45AB5208C2; Wed, 14 Aug 2019 17:10:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565802605; bh=sXqJwjOchb0CiV97OvPL1wdjoasWXfavi5nSr1y8FQ8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=s7rv3BGb/2Fl68/5qFaCjZTgmO+yjCDuTMqbO/SgtGDB0EvnXfTfSYXJmXgelpHOZ +80Mrxkk000EvOTAl2Rz/uZc4yUr73PJQ0Ml6L/oYBxpfps8TvsqPRH/zlBFuqydoH pzq+vNoIOxROXmg5mqt+izRSc6p2aiwWJVqw3CSY= 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 4.19 47/91] allocate_flower_entry: should check for null deref Date: Wed, 14 Aug 2019 19:01:10 +0200 Message-Id: <20190814165751.587517398@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190814165748.991235624@linuxfoundation.org> References: <20190814165748.991235624@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 f2aba5b160c2d..d45c435a599d6 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