Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp904859ybz; Fri, 1 May 2020 10:39:39 -0700 (PDT) X-Google-Smtp-Source: APiQypJX6KZ8uP0U0YqS/obxDTpCtMPOOhtWalZKrCkhGgvxiInIIjIYwWQEVvqZlCgizIPt8Wv5 X-Received: by 2002:a17:906:7d1:: with SMTP id m17mr4150129ejc.247.1588354778860; Fri, 01 May 2020 10:39:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588354778; cv=none; d=google.com; s=arc-20160816; b=wgDDLByTBipDSlTLNA/bQWO3KrOFQeP22A3j6bw87HBtoYdizoZlFDN3tiDQaY5MCw z2aDWqeFDsDeyog34inF7N5VuPLuVY+dtbKF9o1cOqJ60mSb4x6/WPbGfI9DHmTImq7l C6BqDhaY5eR9/Gt6dg9QjSFUn1rdJq4AuMcv9oa75x5iawYg3x6utLuAtJrz6fDxwU2z 0oFGjl4Aja3FLnkxDnl/aothG3gRTLfnowGLg6WE69nvdI5MeZ78jST/ZULJTBflS3lx D22a58PdvB7fvG4FwHGzLzPOSza2CfeeW3qwSYxnk7jrCD5ZY94gZt3zDV7XV3rXeBNr R86w== 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 :message-id:date:subject:cc:to:from; bh=/Z1xJuKot6PMRv/1Ly8o1xpR2MRdON9C/dslRiy6yP8=; b=j2aAQj4vYOOwQLYCJcOu2ov46/eQhrJ+/DA98mG+PDBkOKGCJxQQvtUKVaaZWd6ECu J2mtb7x6aYDXrUw7hx1lZZgMauZQDo2n15h3UZQfT7e4f1z3/zldgKinbPZMUmQ9a3oY /UfSP1upmbHMAUngR+6QRfyucBu4n31DVUFE1OXc1rRGvyfQRQ/lB+1bU8ZxH8xV90LC Ujuk1Ap1hJPzVXlD0XM639E6xFcjuDzE1sp2YSkB/qZVDuzA01PPsDoMtAJlKgiji35H 2kksL0vP+GABuP0Xz5/MXM7hRNtgHw3tL2CtJhsCoO9HMC7e1VVU1NctzzKuNIjxROYR OJFQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cz11si2093270edb.383.2020.05.01.10.39.14; Fri, 01 May 2020 10:39:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729725AbgEARjH (ORCPT + 99 others); Fri, 1 May 2020 13:39:07 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:38787 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729040AbgEARjG (ORCPT ); Fri, 1 May 2020 13:39:06 -0400 Received: from 1.general.cking.uk.vpn ([10.172.193.212] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1jUZcr-0004Ox-2y; Fri, 01 May 2020 17:39:01 +0000 From: Colin King To: Kalle Valo , "David S . Miller" , Lubomir Rintel , Steve deRosier , linux-wireless@vger.kernel.org, netdev@vger.kernel.org Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] libertas_tf: avoid a null dereference in pointer priv Date: Fri, 1 May 2020 18:39:00 +0100 Message-Id: <20200501173900.296658-1-colin.king@canonical.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Colin Ian King 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 --- 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