Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp593053ybt; Fri, 19 Jun 2020 08:55:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzdtFZ2gNfvhpkbWdNshiEuZ0shjews60mFxMPCboXTV8Jgh5voowQLisJwdauPuMaqhnlC X-Received: by 2002:a50:fc0d:: with SMTP id i13mr3950365edr.260.1592582138287; Fri, 19 Jun 2020 08:55:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592582138; cv=none; d=google.com; s=arc-20160816; b=eJLb5gGwFpyo86nOxa08Bn/o4PDezRfoN5Qb1oo+1jqN/XOh3LMpJHSTj5+EzpznEX 0jjP2e+c9PEnzoAIc4d7o23xAIP7m5Vf6vJc6FJieN60AaMCVm/9jXJyTKJjk0gx89Fz ssmMI9mhpAXD8r3JStG4cwJ3wtog9b8JuZNKeEBF0ktNe4jLtPnj8KxzNSBMaVU2zsW4 ex3SBAMDLIHVVvrqWoQRwZBmbkMZY7pg05RNT4SQoxnFAwMcWg/gNmRSB4F4rqFn6La3 T3kGlTd/VLc3ls+niRAw3xYJHoCxqGC+n0L2o31cpRmIxNPUpGDyqiXb7ttQr876bjID hSww== 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=hmxI87m0POy8xs/OKSlazcr2Y110zOVoG2r0yBdP4Aw=; b=sUpgdTfMlS+eep67KWImr1XwBBv5rmy486tcztim7Av+DJdccOi8+KzaFLamf2jLLb SKBfO5wgE6gMr9ay+tN3tiL6709INWSGgOQPcOAVIatzWvuaZv0XloOeovGQ1lrtCfQr DRuhkcXrnp81Pd5iXxQuyjxnDqRn2lP4WVfEZFcM29v1ugTdIQLwxzrmsxE+bYZfKbmZ /r58AY5gWL2TJFG13Rz8+/4/ytTGL/f0I57Ohy3/1O4ISzWTXIq4Z8cw+acjCz4f9YfK Fhwka5RymjR9MeaZOK3vGsC9EbqgiN01uK+OldHb5i4P2bI3VsoIqUSA18yLFTGkPH3u M7RQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=kblRO297; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bc12si4281561edb.348.2020.06.19.08.55.14; Fri, 19 Jun 2020 08:55:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=kblRO297; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2405374AbgFSPwf (ORCPT + 99 others); Fri, 19 Jun 2020 11:52:35 -0400 Received: from mail.kernel.org ([198.145.29.99]:54546 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391970AbgFSPXD (ORCPT ); Fri, 19 Jun 2020 11:23: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 2478F217A0; Fri, 19 Jun 2020 15:23:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592580182; bh=YP48rbtDsCt7cPYauRcjGLjAc3a4MGalUtGGAlwwvpg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kblRO297nVEOxm3cjPY5+iZOWoT+f2h9xCHlsArgqoNMruEdQXg6mt8jwiUhzoYwO E/4N+E+VrUFVGk7TCDGQPsxBjvgj6v9/dqHpp7k0U0cm0ciaFCsafw4FUEM7KSCVLv LLSZXDSkD7jbt8qS+D8Td43I37yNjQ+dFyiWW3wc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Colin Ian King , Kalle Valo , Sasha Levin Subject: [PATCH 5.7 154/376] libertas_tf: avoid a null dereference in pointer priv Date: Fri, 19 Jun 2020 16:31:12 +0200 Message-Id: <20200619141717.612882249@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619141710.350494719@linuxfoundation.org> References: <20200619141710.350494719@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: Colin Ian King [ Upstream commit 049ceac308b0d57c4f06b9fb957cdf95d315cf0b ] Currently there is a check if priv is null when calling lbtf_remove_card but not in a previous call to if_usb_reset_dev that can also dereference priv. Fix this by also only calling lbtf_remove_card if priv is null. It is noteable that there don't seem to be any bugs reported that the null pointer dereference has ever occurred, so I'm not sure if the null check is required, but since we're doing a null check anyway it should be done for both function calls. Addresses-Coverity: ("Dereference before null check") Fixes: baa0280f08c7 ("libertas_tf: don't defer firmware loading until start()") Signed-off-by: Colin Ian King Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20200501173900.296658-1-colin.king@canonical.com Signed-off-by: Sasha Levin --- drivers/net/wireless/marvell/libertas_tf/if_usb.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/marvell/libertas_tf/if_usb.c b/drivers/net/wireless/marvell/libertas_tf/if_usb.c index 25ac9db35dbf..bedc09215088 100644 --- a/drivers/net/wireless/marvell/libertas_tf/if_usb.c +++ b/drivers/net/wireless/marvell/libertas_tf/if_usb.c @@ -247,10 +247,10 @@ static void if_usb_disconnect(struct usb_interface *intf) lbtf_deb_enter(LBTF_DEB_MAIN); - if_usb_reset_device(priv); - - if (priv) + if (priv) { + if_usb_reset_device(priv); lbtf_remove_card(priv); + } /* Unlink and free urb */ if_usb_free(cardp); -- 2.25.1