Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1616294ybv; Fri, 21 Feb 2020 00:21:12 -0800 (PST) X-Google-Smtp-Source: APXvYqzuJaSVQiDskd8EjgJvPk/n+mCDNRv7dbNjqlJv8zSnlHnv8Cl3dzQ29DKyKKKv2IThOH1f X-Received: by 2002:a9d:111:: with SMTP id 17mr26950573otu.256.1582273272646; Fri, 21 Feb 2020 00:21:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582273272; cv=none; d=google.com; s=arc-20160816; b=NeCZGgFuNVWcoiYwPpJL7X/tUMeYtvNLTSKs2k68tjT7SsDhdY1Y2l0KTkZeYV1bb4 ivaGKfTJ79Fjwsigi/gqsYzwkJiPOVBGqg97Z85g35xz1EnT19oJOWZaljnch6ssOlQT Ejb6PADEV4rs4t+fHJhfbDK0vVZbHkmWp2irFI2IGEIT/Q+dIbC0xvZZfpuNb5m+U5tu QBlCe1eYzYrZsVa9OBz7xuNmUZf4v2knmf8f7P1/aRQrs414tEQBK2j1AebaXwY7MKO4 sU6jgTkuZspXLvL1dIkByVlWUCN8c8Pi6qJQLz8ovpw+Db2xmOT9EQdhorecUncHvobO 4SDA== 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=1JE6p/89dg094JyuC8vQzmSYlXzR783PYTAveKYE5I0=; b=ExAqtRCdFK8NsW75PbFP1rkyKivM+47ja8Yv2GJthqBVwTtYun1uUddZITMLPjJGHJ XjRi2SMz4L/i56SxEW5G/Vz8pSsh2bX68wmiT1ZbBq+FgJQz5aBeEg+KUAQvjFI1B5NT jNu5Ob1/E/HcrbdOFGcGWmhlXFYaviih+jblXJnYj86y8kEmCr37KLNfEKNceOqpgDq5 29NqUGb9k/8uLxDGV8IJ/5fRO2q9+2b/da/2aV9nS28ork4g+XOnnhinFH/8YhTsXIBl ucJu4CHWYoSCdfp2gghQ1Vdie76nUuYhs3h2gmeBkHhWzCdX93li5D7FpZhelePPof8U H78g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="YawEy/yW"; 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 t25si471023oic.183.2020.02.21.00.21.00; Fri, 21 Feb 2020 00:21:12 -0800 (PST) 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="YawEy/yW"; 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 S2388028AbgBUITb (ORCPT + 99 others); Fri, 21 Feb 2020 03:19:31 -0500 Received: from mail.kernel.org ([198.145.29.99]:58048 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388024AbgBUIT3 (ORCPT ); Fri, 21 Feb 2020 03:19:29 -0500 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 A4C5624691; Fri, 21 Feb 2020 08:19:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1582273169; bh=37Tl3sdRVJVadsU+L3wETW4srSquGpwjxB81nM98w+Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YawEy/yWIypE7RdU2qJLkyvi4bObUcZXY7FRROitbahWMFdRGTz/U3wecEG6jHFiU 2nFxv9VGFVM0iQIAC8PoNIiUTn1oY4a9TloU1y1DjtKnDM/QAGEKBayIKOYvD6SzuF s67o9yOtctSZqp9JSq4yEl/CF1w5ZD2PasGcwDLE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Aditya Pakki , "David S. Miller" , Sasha Levin Subject: [PATCH 4.19 071/191] fore200e: Fix incorrect checks of NULL pointer dereference Date: Fri, 21 Feb 2020 08:40:44 +0100 Message-Id: <20200221072259.864567901@linuxfoundation.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200221072250.732482588@linuxfoundation.org> References: <20200221072250.732482588@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 From: Aditya Pakki [ Upstream commit bbd20c939c8aa3f27fa30e86691af250bf92973a ] In fore200e_send and fore200e_close, the pointers from the arguments are dereferenced in the variable declaration block and then checked for NULL. The patch fixes these issues by avoiding NULL pointer dereferences. Signed-off-by: Aditya Pakki Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/atm/fore200e.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/drivers/atm/fore200e.c b/drivers/atm/fore200e.c index 99a38115b0a8f..86aab14872fd0 100644 --- a/drivers/atm/fore200e.c +++ b/drivers/atm/fore200e.c @@ -1504,12 +1504,14 @@ fore200e_open(struct atm_vcc *vcc) static void fore200e_close(struct atm_vcc* vcc) { - struct fore200e* fore200e = FORE200E_DEV(vcc->dev); struct fore200e_vcc* fore200e_vcc; + struct fore200e* fore200e; struct fore200e_vc_map* vc_map; unsigned long flags; ASSERT(vcc); + fore200e = FORE200E_DEV(vcc->dev); + ASSERT((vcc->vpi >= 0) && (vcc->vpi < 1<vci >= 0) && (vcc->vci < 1<dev); - struct fore200e_vcc* fore200e_vcc = FORE200E_VCC(vcc); + struct fore200e* fore200e; + struct fore200e_vcc* fore200e_vcc; struct fore200e_vc_map* vc_map; - struct host_txq* txq = &fore200e->host_txq; + struct host_txq* txq; struct host_txq_entry* entry; struct tpd* tpd; struct tpd_haddr tpd_haddr; @@ -1570,9 +1572,18 @@ fore200e_send(struct atm_vcc *vcc, struct sk_buff *skb) unsigned char* data; unsigned long flags; - ASSERT(vcc); - ASSERT(fore200e); - ASSERT(fore200e_vcc); + if (!vcc) + return -EINVAL; + + fore200e = FORE200E_DEV(vcc->dev); + fore200e_vcc = FORE200E_VCC(vcc); + + if (!fore200e) + return -EINVAL; + + txq = &fore200e->host_txq; + if (!fore200e_vcc) + return -EINVAL; if (!test_bit(ATM_VF_READY, &vcc->flags)) { DPRINTK(1, "VC %d.%d.%d not ready for tx\n", vcc->itf, vcc->vpi, vcc->vpi); -- 2.20.1