From patchwork Sat Mar 30 09:31:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 10878219 X-Patchwork-Delegate: luca@coelho.fi Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 354FD15AC for ; Sat, 30 Mar 2019 09:32:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1ED77290CC for ; Sat, 30 Mar 2019 09:32:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 12A02290D6; Sat, 30 Mar 2019 09:32:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AA57A290CC for ; Sat, 30 Mar 2019 09:32:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730532AbfC3Jb6 (ORCPT ); Sat, 30 Mar 2019 05:31:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:33300 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730453AbfC3Jb5 (ORCPT ); Sat, 30 Mar 2019 05:31:57 -0400 Received: from localhost (unknown [62.119.166.9]) (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 BFA4E2075E; Sat, 30 Mar 2019 09:31:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553938316; bh=tgEJJsEp8HLK1niWW9oIcWkzJIxjOzFoVIV8bUJ0VlE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=NRwgdgKda486H3zPX22uXby3nX7q1xj7baYk1kYymUawG8cEyABTO+iilCzlPTI// zzjaqOSVoJDzem209CKzJiORgVgakubh7wysfDYV/ze+n/lYK3MSq0if8jUA10yGeR lHv9ukJjMBGtj7HXMNUWG/cG4CI9jFRwjiRU9ltg= Date: Sat, 30 Mar 2019 10:31:52 +0100 From: Greg Kroah-Hartman To: Luca Coelho Cc: Laura Abbott , linux-kernel@vger.kernel.org, Johannes Berg , Emmanuel Grumbach , Intel Linux Wireless , Kalle Valo , linux-wireless@vger.kernel.org, Luca Coelho , stable Subject: [PATCH] iwlwifi: properly check debugfs dentry before using it Message-ID: <20190330093152.GB14300@kroah.com> References: <20190122152151.16139-24-gregkh@linuxfoundation.org> <03bb68be-8e42-a463-2d57-3be051dc2016@redhat.com> <20190327012600.GA3649@kroah.com> <5660d50d-6cbf-3b36-6e6c-312b1617ed23@redhat.com> <20190327015346.GA17979@kroah.com> <5f9c8beda0e925b079aa9342ce1c9523659837a4.camel@coelho.fi> <20190330092247.GA14300@kroah.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20190330092247.GA14300@kroah.com> User-Agent: Mutt/1.11.4 (2019-03-13) Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP debugfs can now report an error code if something went wrong instead of just NULL. So if the return value is to be used as a "real" dentry, it needs to be checked if it is an error before dereferencing it. This is now happening because of ff9fb72bc077 ("debugfs: return error values, not NULL"). If multiple iwlwifi devices are in the system, this can cause problems when the driver attempts to create the main debugfs directory again. Later on in the code we fail horribly by trying to dereference a pointer that is an error value. Reported-by: Laura Abbott Cc: Johannes Berg Cc: Emmanuel Grumbach Cc: Luca Coelho Cc: Intel Linux Wireless Cc: Kalle Valo Cc: stable # 5.0 Signed-off-by: Greg Kroah-Hartman Reported-by: Gabriel Ramirez diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/debugfs-vif.c b/drivers/net/wireless/intel/iwlwifi/mvm/debugfs-vif.c index 2453ceabf00d..6925527d8457 100644 --- a/drivers/net/wireless/intel/iwlwifi/mvm/debugfs-vif.c +++ b/drivers/net/wireless/intel/iwlwifi/mvm/debugfs-vif.c @@ -774,8 +774,7 @@ void iwl_mvm_vif_dbgfs_register(struct iwl_mvm *mvm, struct ieee80211_vif *vif) return; mvmvif->dbgfs_dir = debugfs_create_dir("iwlmvm", dbgfs_dir); - - if (!mvmvif->dbgfs_dir) { + if (IS_ERR_OR_NULL(mvmvif->dbgfs_dir)) { IWL_ERR(mvm, "Failed to create debugfs directory under %pd\n", dbgfs_dir); return;