Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp836901ybi; Fri, 12 Jul 2019 05:28:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqwVU6Uce9Uw3HlkrFYNBy0LE6z+BdY8ly8CwWoePaAsl0ept+o9BwegZmY13bEpyauaqOoX X-Received: by 2002:a17:90a:2488:: with SMTP id i8mr11254141pje.123.1562934507652; Fri, 12 Jul 2019 05:28:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562934507; cv=none; d=google.com; s=arc-20160816; b=iCyJiR336rOLEXRA32QiSP8eqvXbzZRogVjP+I6PUzK1VjrEIast5W8ESJk0LMTNUA 5u7iM7GiBdzIh2NIMFlO11ghE5ECzRHbNBQHocNgA0GkwEl33MHmcIoB10XYTwZro+M2 5N/U7RUhoUkmE6qQlAlyZZojRdSYxXeTL6m0YVbR0jc1UuthVmz1UtmPwBHBzMsJeZU0 iztTsjREYnH5B0IiL9aq3hvZYWbiiyXo4DmcPxhWb4eYACYOE+cYlrAGtnM8vvMXIlZ5 FzDfrUjt05c1x9UOgjHwpVlEoG78tvTTbBq31/7gy1nQnCQ4WmHKHtSZxyZE4Qk0nB3q pQpw== 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=rfauHakA89Rjd7xjj29HV5dX/9jnJta4w5mxASvpXsw=; b=B8AUzuBvZWfasaHEAApY0dr1P4TcmmGKTy1TNCAhLVIE3WQtZNoNlzTxkoBsxhV1os m2+7iNdcsEfEFbeGGg2WNtse14JJmLEtMIqN2ncJUy0S6Vxy1IUM3H736IP5OUZANYf7 Fn+e0LV1WII6/wo5g0K6yoSIqEgwyaKwDg6xEm50M/9lkB3q8qKe86+sMJEvmpJ70+S5 Mw8qxJOUQmss9zHIxNSpgmnD0brnnlfO78LzmF7RTJxOuuQxDKorkqI72s1/QWTicKTW LJZQBTRZh+A70Rf5ZPGHpnvFxpRe8AsNXKh4VKOtXYGgJKBMTewAe1/0OqruwK89/6cT abQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=JyT7TYvA; 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 cp10si1242407plb.301.2019.07.12.05.28.12; Fri, 12 Jul 2019 05:28:27 -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=JyT7TYvA; 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 S1728029AbfGLM1J (ORCPT + 99 others); Fri, 12 Jul 2019 08:27:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:38974 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728542AbfGLM1D (ORCPT ); Fri, 12 Jul 2019 08:27:03 -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 C87C821670; Fri, 12 Jul 2019 12:27:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1562934422; bh=brf5VmPedC1NgBTv6Aa4yQ1ph1WGBNQpZpbYVc0EDH0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JyT7TYvAfNiqu72CzqS3vNp1WfcURAUpptLHwXLU1wTXJMkBjqrJNVIimdBMWhvHt ZfL3mPtBDqCjX1FHtNcIhxmw3+KBs5CiyBCm4mdD98z3SswAHpXYE/X3tOyxZQelNo bgNpQ4yLnM1IYOhDNjO8Ji4KAzCb/yeO//yIxk40= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ilya Maximets , Jonathan Lemon , Daniel Borkmann , Sasha Levin Subject: [PATCH 5.1 050/138] xdp: check device pointer before clearing Date: Fri, 12 Jul 2019 14:18:34 +0200 Message-Id: <20190712121630.584296399@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190712121628.731888964@linuxfoundation.org> References: <20190712121628.731888964@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 01d76b5317003e019ace561a9b775f51aafdfdc4 ] We should not call 'ndo_bpf()' or 'dev_put()' with NULL argument. Fixes: c9b47cc1fabc ("xsk: fix bug when trying to use both copy and zero-copy on one queue id") Signed-off-by: Ilya Maximets Acked-by: Jonathan Lemon Signed-off-by: Daniel Borkmann Signed-off-by: Sasha Levin --- net/xdp/xdp_umem.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/net/xdp/xdp_umem.c b/net/xdp/xdp_umem.c index 989e52386c35..2f7e2c33a812 100644 --- a/net/xdp/xdp_umem.c +++ b/net/xdp/xdp_umem.c @@ -143,6 +143,9 @@ static void xdp_umem_clear_dev(struct xdp_umem *umem) struct netdev_bpf bpf; int err; + if (!umem->dev) + return; + if (umem->zc) { bpf.command = XDP_SETUP_XSK_UMEM; bpf.xsk.umem = NULL; @@ -156,11 +159,9 @@ static void xdp_umem_clear_dev(struct xdp_umem *umem) WARN(1, "failed to disable umem!\n"); } - if (umem->dev) { - rtnl_lock(); - xdp_clear_umem_at_qid(umem->dev, umem->queue_id); - rtnl_unlock(); - } + rtnl_lock(); + xdp_clear_umem_at_qid(umem->dev, umem->queue_id); + rtnl_unlock(); if (umem->zc) { dev_put(umem->dev); -- 2.20.1