linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Kefeng Wang <wangkefeng.wang@huawei.com>,
	Hans Verkuil <hverkuil-cisco@xs4all.nl>,
	Mauro Carvalho Chehab <mchehab+samsung@kernel.org>,
	Sasha Levin <sashal@kernel.org>,
	linux-media@vger.kernel.org
Subject: [PATCH AUTOSEL 5.2 051/249] media: saa7164: fix remove_proc_entry warning
Date: Mon, 15 Jul 2019 09:43:36 -0400	[thread overview]
Message-ID: <20190715134655.4076-51-sashal@kernel.org> (raw)
In-Reply-To: <20190715134655.4076-1-sashal@kernel.org>

From: Kefeng Wang <wangkefeng.wang@huawei.com>

[ 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 <wangkefeng.wang@huawei.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
[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 <mchehab+samsung@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 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


  parent reply	other threads:[~2019-07-15 13:49 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20190715134655.4076-1-sashal@kernel.org>
2019-07-15 13:43 ` [PATCH AUTOSEL 5.2 019/249] media: dvb: usb: fix use after free in dvb_usb_device_exit Sasha Levin
2019-07-15 13:43 ` [PATCH AUTOSEL 5.2 020/249] media: spi: IR LED: add missing of table registration Sasha Levin
2019-07-15 13:43 ` [PATCH AUTOSEL 5.2 022/249] media: ov7740: avoid invalid framesize setting Sasha Levin
2019-07-15 13:43 ` [PATCH AUTOSEL 5.2 023/249] media: marvell-ccic: fix DMA s/g desc number calculation Sasha Levin
2019-07-15 13:43 ` [PATCH AUTOSEL 5.2 025/249] media: vpss: fix a potential NULL pointer dereference Sasha Levin
2019-07-15 13:43 ` [PATCH AUTOSEL 5.2 026/249] media: media_device_enum_links32: clean a reserved field Sasha Levin
2019-07-15 13:43 ` [PATCH AUTOSEL 5.2 028/249] media: venus: firmware: fix leaked of_node references Sasha Levin
2019-07-15 13:43 ` [PATCH AUTOSEL 5.2 042/249] media: vim2m: fix two double-free issues Sasha Levin
2019-07-15 13:43 ` [PATCH AUTOSEL 5.2 043/249] media: v4l2-core: fix use-after-free error Sasha Levin
2019-07-15 13:43 ` [PATCH AUTOSEL 5.2 045/249] media: usb:zr364xx:Fix KASAN:null-ptr-deref Read in zr364xx_vidioc_querycap Sasha Levin
2019-07-15 13:43 ` [PATCH AUTOSEL 5.2 050/249] media: mc-device.c: don't memset __user pointer contents Sasha Levin
2019-07-15 13:43 ` Sasha Levin [this message]
2019-07-15 13:43 ` [PATCH AUTOSEL 5.2 053/249] media: staging: media: davinci_vpfe: - Fix for memory leak if decoder initialization fails Sasha Levin
2019-07-15 13:43 ` [PATCH AUTOSEL 5.2 058/249] tua6100: Avoid build warnings Sasha Levin
2019-07-15 13:43 ` [PATCH AUTOSEL 5.2 062/249] media: platform: ao-cec-g12a: disable regmap fast_io for cec bus regmap Sasha Levin
2019-07-15 13:43 ` [PATCH AUTOSEL 5.2 063/249] media: wl128x: Fix some error handling in fm_v4l2_init_video_device() Sasha Levin
2019-07-15 13:43 ` [PATCH AUTOSEL 5.2 068/249] media: imx7-mipi-csis: Propagate the error if clock enabling fails Sasha Levin
2019-07-15 13:43 ` [PATCH AUTOSEL 5.2 070/249] media: aspeed: change irq to threaded irq Sasha Levin
2019-07-15 13:43 ` [PATCH AUTOSEL 5.2 071/249] media: aspeed: fix a kernel warning on clk control Sasha Levin
2019-07-15 13:44 ` [PATCH AUTOSEL 5.2 087/249] media: uvcvideo: Fix access to uninitialized fields on probe error Sasha Levin
2019-07-15 13:44 ` [PATCH AUTOSEL 5.2 088/249] media: fdp1: Support M3N and E3 platforms Sasha Levin
2019-07-15 13:44 ` [PATCH AUTOSEL 5.2 094/249] media: davinci: vpif_capture: fix memory leak in vpif_probe() Sasha Levin
2019-07-15 13:44 ` [PATCH AUTOSEL 5.2 096/249] media: s5p-mfc: fix reading min scratch buffer size on MFC v6/v7 Sasha Levin
2019-07-15 13:45 ` [PATCH AUTOSEL 5.2 142/249] media: staging: davinci: fix memory leaks and check for allocation failure Sasha Levin
2019-07-15 13:45 ` [PATCH AUTOSEL 5.2 144/249] media: s5p-mfc: Make additional clocks optional Sasha Levin
2019-07-15 13:45 ` [PATCH AUTOSEL 5.2 145/249] media: i2c: fix warning same module names Sasha Levin
2019-07-15 13:45 ` [PATCH AUTOSEL 5.2 148/249] media: mt9m111: fix fw-node refactoring Sasha Levin
2019-07-15 13:45 ` [PATCH AUTOSEL 5.2 151/249] media: coda: fix mpeg2 sequence number handling Sasha Levin
2019-07-15 13:45 ` [PATCH AUTOSEL 5.2 152/249] media: coda: fix last buffer handling in V4L2_ENC_CMD_STOP Sasha Levin
2019-07-15 13:45 ` [PATCH AUTOSEL 5.2 153/249] media: coda: increment sequence offset for the last returned frame Sasha Levin
2019-07-15 13:45 ` [PATCH AUTOSEL 5.2 154/249] media: vimc: cap: check v4l2_fill_pixfmt return value Sasha Levin
2019-07-15 13:45 ` [PATCH AUTOSEL 5.2 155/249] media: hdpvr: fix locking and a missing msleep Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190715134655.4076-51-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=hverkuil-cisco@xs4all.nl \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab+samsung@kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=wangkefeng.wang@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).