Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp10618343ybi; Thu, 25 Jul 2019 02:31:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqwRWY+EUvVrVM/DylYWmZtV1aHtPDWYqpEoIfFCOJTfV+wvHfE8HCI+ZMVoMQFkYpd1IswY X-Received: by 2002:a17:902:5ac4:: with SMTP id g4mr92155233plm.80.1564047069570; Thu, 25 Jul 2019 02:31:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564047069; cv=none; d=google.com; s=arc-20160816; b=R6kgAq+1vzwHDMIVW4IEK5w6VlOqjc79mAevlihPB3HOmvYH6ET7ljzdu88mb1BSBX /WClijsN98rpuCXBJ5zGBLriXrqEUEotBAxlFRiDS4ei0gIrdL7eBJsyFVCYYPDABY7T VWrnoIhRTiuZkwGr+wyftSNkdN2vVGeAXXbNafCkn2o2bydUPd4MYjHXPHwQh/xWA5vL GDSxFVOfHOl917CaSrVnGsvZxCtOiX6AQdyDDmMRYb91L9paF9Gr0jsKDtULE53arUGa Dd4okR+H0P+QX9IQVEg+S6ln9tlWgmQm4u/isSmL0jjlD0tJH0IBUJMJxTYhQ8h7yD2p vi+A== 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=lpGI2sysyns8/z6dFFdzEhyrveT4+T1kifXm7F5mOnY=; b=je7g6MGW2FTIzQph0zIhG1/TvekVa90R4PeANSaYvZ2QabSe/288rbdRw5MeqhOBQA HN/D2Ccgszu8UxOwFINMuc7DM4BzqiaaUMWQ3ksJehQOgGKaet9Myu6b9GpTR4fmJYos +rTXfnIU9jYjH7EW2dKEdUrNeqFYWlR9gKEwFYNp8iGzvcYeai3syuxTRZFNaY45kVf0 VRdla9ZMDXKjtuXRKW2MJuRrDJ9+S/Mx29tnf3ciKnIrtd2sfRDCk6l1kdG0H8kQKCBf Hzy6TBYPeIks0EK0tyAO7Zx4JHgucH13Y2X+anMCm1VHnwDfuWhEU3x3s/JTfSK07+BE Ywpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=s444G6Oh; 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 m15si16360601pff.267.2019.07.25.02.30.48; Thu, 25 Jul 2019 02:31:09 -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=s444G6Oh; 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 S2390242AbfGXUgV (ORCPT + 99 others); Wed, 24 Jul 2019 16:36:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:41428 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388004AbfGXTYy (ORCPT ); Wed, 24 Jul 2019 15:24:54 -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 143F921951; Wed, 24 Jul 2019 19:24:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563996293; bh=JyOwmzys1P/HTssEN1TQGUn5WUnChrmVDD/EuknGGXQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=s444G6Ohb/CEKOMatfbnzo+PwP1fDr8rDpFlDJ2N2FBlTf5onh1Rb9EJOAQLMofPP 4ToBa/plaUwcPJrmb/kNOxxfAzv0Il8BUYG8Q5nchlcXsGs+236uZ7y/DTbvpvEE5S AmR7Td+j4X266uQjI6igIuPvoXKOVX/ePiS+hjd4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kefeng Wang , Hans Verkuil , Mauro Carvalho Chehab , Sasha Levin Subject: [PATCH 5.2 048/413] media: saa7164: fix remove_proc_entry warning Date: Wed, 24 Jul 2019 21:15:39 +0200 Message-Id: <20190724191738.979704618@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190724191735.096702571@linuxfoundation.org> References: <20190724191735.096702571@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 50710eeefbc1ed25375942aad0c4d1eb4af0f330 ] if saa7164_proc_create() fails, saa7164_fini() will trigger a warning, name 'saa7164' WARNING: CPU: 1 PID: 6311 at fs/proc/generic.c:672 remove_proc_entry+0x1e8/0x3a0 ? remove_proc_entry+0x1e8/0x3a0 ? try_stop_module+0x7b/0x240 ? proc_readdir+0x70/0x70 ? rcu_read_lock_sched_held+0xd7/0x100 saa7164_fini+0x13/0x1f [saa7164] __x64_sys_delete_module+0x30c/0x480 ? __ia32_sys_delete_module+0x480/0x480 ? __x64_sys_clock_gettime+0x11e/0x1c0 ? __x64_sys_timer_create+0x1a0/0x1a0 ? trace_hardirqs_off_caller+0x40/0x180 ? do_syscall_64+0x18/0x450 do_syscall_64+0x9f/0x450 entry_SYSCALL_64_after_hwframe+0x49/0xbe Fix it by checking the return of proc_create_single() before calling remove_proc_entry(). Signed-off-by: Kefeng Wang Signed-off-by: Hans Verkuil [hverkuil-cisco@xs4all.nl: use 0444 instead of S_IRUGO] [hverkuil-cisco@xs4all.nl: use pr_info instead of KERN_INFO] Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/media/pci/saa7164/saa7164-core.c | 33 ++++++++++++++++-------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/drivers/media/pci/saa7164/saa7164-core.c b/drivers/media/pci/saa7164/saa7164-core.c index c594aff92e70..9ae04e18e6c6 100644 --- a/drivers/media/pci/saa7164/saa7164-core.c +++ b/drivers/media/pci/saa7164/saa7164-core.c @@ -1112,16 +1112,25 @@ static int saa7164_proc_show(struct seq_file *m, void *v) return 0; } +static struct proc_dir_entry *saa7164_pe; + static int saa7164_proc_create(void) { - struct proc_dir_entry *pe; - - pe = proc_create_single("saa7164", S_IRUGO, NULL, saa7164_proc_show); - if (!pe) + saa7164_pe = proc_create_single("saa7164", 0444, NULL, saa7164_proc_show); + if (!saa7164_pe) return -ENOMEM; return 0; } + +static void saa7164_proc_destroy(void) +{ + if (saa7164_pe) + remove_proc_entry("saa7164", NULL); +} +#else +static int saa7164_proc_create(void) { return 0; } +static void saa7164_proc_destroy(void) {} #endif static int saa7164_thread_function(void *data) @@ -1493,19 +1502,21 @@ static struct pci_driver saa7164_pci_driver = { static int __init saa7164_init(void) { - printk(KERN_INFO "saa7164 driver loaded\n"); + int ret = pci_register_driver(&saa7164_pci_driver); + + if (ret) + return ret; -#ifdef CONFIG_PROC_FS saa7164_proc_create(); -#endif - return pci_register_driver(&saa7164_pci_driver); + + pr_info("saa7164 driver loaded\n"); + + return 0; } static void __exit saa7164_fini(void) { -#ifdef CONFIG_PROC_FS - remove_proc_entry("saa7164", NULL); -#endif + saa7164_proc_destroy(); pci_unregister_driver(&saa7164_pci_driver); } -- 2.20.1