All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org, Sean Young <sean@mess.org>,
	Mauro Carvalho Chehab <mchehab@s-opensource.com>
Subject: [PATCH 4.10 44/48] [media] serial_ir: ensure were ready to receive interrupts
Date: Thu, 16 Mar 2017 23:30:28 +0900	[thread overview]
Message-ID: <20170316142922.983457516@linuxfoundation.org> (raw)
In-Reply-To: <20170316142920.761502205@linuxfoundation.org>

4.10-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Sean Young <sean@mess.org>

commit 0265634eb9e04a16ae99941c320718c38eb865e0 upstream.

When the interrupt requested with devm_request_irq(), serial_ir.rcdev
is still null so will cause null deference if the irq handler is called
early on.

Also ensure that timeout_timer is setup.

Link: http://lkml.kernel.org/r/CA+55aFxsh2uF8gi5sN_guY3Z+tiLv7LpJYKBw+y8vqLzp+TsnQ@mail.gmail.com

[mchehab@s-opensource.com: moved serial_ir_probe() back to its original place]

Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/media/rc/serial_ir.c |  115 +++++++++++++++++++++----------------------
 1 file changed, 58 insertions(+), 57 deletions(-)

--- a/drivers/media/rc/serial_ir.c
+++ b/drivers/media/rc/serial_ir.c
@@ -471,10 +471,65 @@ static int hardware_init_port(void)
 	return 0;
 }
 
+/* Needed by serial_ir_probe() */
+static int serial_ir_tx(struct rc_dev *dev, unsigned int *txbuf,
+			unsigned int count);
+static int serial_ir_tx_duty_cycle(struct rc_dev *dev, u32 cycle);
+static int serial_ir_tx_carrier(struct rc_dev *dev, u32 carrier);
+static int serial_ir_open(struct rc_dev *rcdev);
+static void serial_ir_close(struct rc_dev *rcdev);
+
 static int serial_ir_probe(struct platform_device *dev)
 {
+	struct rc_dev *rcdev;
 	int i, nlow, nhigh, result;
 
+	rcdev = devm_rc_allocate_device(&dev->dev);
+	if (!rcdev)
+		return -ENOMEM;
+
+	if (hardware[type].send_pulse && hardware[type].send_space)
+		rcdev->tx_ir = serial_ir_tx;
+	if (hardware[type].set_send_carrier)
+		rcdev->s_tx_carrier = serial_ir_tx_carrier;
+	if (hardware[type].set_duty_cycle)
+		rcdev->s_tx_duty_cycle = serial_ir_tx_duty_cycle;
+
+	switch (type) {
+	case IR_HOMEBREW:
+		rcdev->input_name = "Serial IR type home-brew";
+		break;
+	case IR_IRDEO:
+		rcdev->input_name = "Serial IR type IRdeo";
+		break;
+	case IR_IRDEO_REMOTE:
+		rcdev->input_name = "Serial IR type IRdeo remote";
+		break;
+	case IR_ANIMAX:
+		rcdev->input_name = "Serial IR type AnimaX";
+		break;
+	case IR_IGOR:
+		rcdev->input_name = "Serial IR type IgorPlug";
+		break;
+	}
+
+	rcdev->input_phys = KBUILD_MODNAME "/input0";
+	rcdev->input_id.bustype = BUS_HOST;
+	rcdev->input_id.vendor = 0x0001;
+	rcdev->input_id.product = 0x0001;
+	rcdev->input_id.version = 0x0100;
+	rcdev->open = serial_ir_open;
+	rcdev->close = serial_ir_close;
+	rcdev->dev.parent = &serial_ir.pdev->dev;
+	rcdev->driver_type = RC_DRIVER_IR_RAW;
+	rcdev->allowed_protocols = RC_BIT_ALL;
+	rcdev->driver_name = KBUILD_MODNAME;
+	rcdev->map_name = RC_MAP_RC6_MCE;
+	rcdev->timeout = IR_DEFAULT_TIMEOUT;
+	rcdev->rx_resolution = 250000;
+
+	serial_ir.rcdev = rcdev;
+
 	result = devm_request_irq(&dev->dev, irq, serial_ir_irq_handler,
 				  share_irq ? IRQF_SHARED : 0,
 				  KBUILD_MODNAME, &hardware);
@@ -533,7 +588,8 @@ static int serial_ir_probe(struct platfo
 			 sense ? "low" : "high");
 
 	dev_dbg(&dev->dev, "Interrupt %d, port %04x obtained\n", irq, io);
-	return 0;
+
+	return devm_rc_register_device(&dev->dev, rcdev);
 }
 
 static int serial_ir_open(struct rc_dev *rcdev)
@@ -704,7 +760,6 @@ static void serial_ir_exit(void)
 
 static int __init serial_ir_init_module(void)
 {
-	struct rc_dev *rcdev;
 	int result;
 
 	switch (type) {
@@ -735,69 +790,15 @@ static int __init serial_ir_init_module(
 		sense = !!sense;
 
 	result = serial_ir_init();
-	if (result)
-		return result;
-
-	rcdev = devm_rc_allocate_device(&serial_ir.pdev->dev);
-	if (!rcdev) {
-		result = -ENOMEM;
-		goto serial_cleanup;
-	}
-
-	if (hardware[type].send_pulse && hardware[type].send_space)
-		rcdev->tx_ir = serial_ir_tx;
-	if (hardware[type].set_send_carrier)
-		rcdev->s_tx_carrier = serial_ir_tx_carrier;
-	if (hardware[type].set_duty_cycle)
-		rcdev->s_tx_duty_cycle = serial_ir_tx_duty_cycle;
-
-	switch (type) {
-	case IR_HOMEBREW:
-		rcdev->input_name = "Serial IR type home-brew";
-		break;
-	case IR_IRDEO:
-		rcdev->input_name = "Serial IR type IRdeo";
-		break;
-	case IR_IRDEO_REMOTE:
-		rcdev->input_name = "Serial IR type IRdeo remote";
-		break;
-	case IR_ANIMAX:
-		rcdev->input_name = "Serial IR type AnimaX";
-		break;
-	case IR_IGOR:
-		rcdev->input_name = "Serial IR type IgorPlug";
-		break;
-	}
-
-	rcdev->input_phys = KBUILD_MODNAME "/input0";
-	rcdev->input_id.bustype = BUS_HOST;
-	rcdev->input_id.vendor = 0x0001;
-	rcdev->input_id.product = 0x0001;
-	rcdev->input_id.version = 0x0100;
-	rcdev->open = serial_ir_open;
-	rcdev->close = serial_ir_close;
-	rcdev->dev.parent = &serial_ir.pdev->dev;
-	rcdev->driver_type = RC_DRIVER_IR_RAW;
-	rcdev->allowed_protocols = RC_BIT_ALL;
-	rcdev->driver_name = KBUILD_MODNAME;
-	rcdev->map_name = RC_MAP_RC6_MCE;
-	rcdev->timeout = IR_DEFAULT_TIMEOUT;
-	rcdev->rx_resolution = 250000;
-
-	serial_ir.rcdev = rcdev;
-
-	result = rc_register_device(rcdev);
-
 	if (!result)
 		return 0;
-serial_cleanup:
+
 	serial_ir_exit();
 	return result;
 }
 
 static void __exit serial_ir_exit_module(void)
 {
-	rc_unregister_device(serial_ir.rcdev);
 	serial_ir_exit();
 }
 

  parent reply	other threads:[~2017-03-16 14:36 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-16 14:29 [PATCH 4.10 00/48] 4.10.4-stable review Greg Kroah-Hartman
2017-03-16 14:29 ` [PATCH 4.10 01/48] iio: 104-quad-8: Fix off-by-one error when addressing flag register Greg Kroah-Hartman
2017-03-16 14:29 ` [PATCH 4.10 02/48] ARM: qcom_defconfig: Enable RPM/RPM-SMD clocks Greg Kroah-Hartman
2017-03-16 14:29 ` [PATCH 4.10 03/48] USB: serial: digi_acceleport: fix OOB data sanity check Greg Kroah-Hartman
2017-03-16 14:29 ` [PATCH 4.10 04/48] USB: serial: digi_acceleport: fix OOB-event processing Greg Kroah-Hartman
2017-03-16 14:29 ` [PATCH 4.10 05/48] crypto: improve gcc optimization flags for serpent and wp512 Greg Kroah-Hartman
2017-03-16 14:29 ` [PATCH 4.10 06/48] MIPS: Update defconfigs for NF_CT_PROTO_DCCP/UDPLITE change Greg Kroah-Hartman
2017-03-16 14:29 ` [PATCH 4.10 07/48] MIPS: VDSO: avoid duplicate CAC_BASE definition Greg Kroah-Hartman
2017-03-16 14:29 ` [PATCH 4.10 08/48] MIPS: ip27: Disable qlge driver in defconfig Greg Kroah-Hartman
2017-03-16 14:29 ` [PATCH 4.10 09/48] MIPS: Update ip27_defconfig for SCSI_DH change Greg Kroah-Hartman
2017-03-16 14:29 ` [PATCH 4.10 10/48] MIPS: ip22: Fix ip28 build for modern gcc Greg Kroah-Hartman
2017-03-16 14:29 ` [PATCH 4.10 11/48] MIPS: Update lemote2f_defconfig for CPU_FREQ_STAT change Greg Kroah-Hartman
2017-03-16 14:29 ` [PATCH 4.10 12/48] mtd: pmcmsp: use kstrndup instead of kmalloc+strncpy Greg Kroah-Hartman
2017-03-16 14:29 ` [PATCH 4.10 13/48] MIPS: ralink: Cosmetic change to prom_init() Greg Kroah-Hartman
2017-03-16 14:29 ` [PATCH 4.10 14/48] MIPS: ralink: Remove unused timer functions Greg Kroah-Hartman
2017-03-16 14:29 ` [PATCH 4.10 15/48] MIPS: ralink: Remove unused rt*_wdt_reset functions Greg Kroah-Hartman
2017-03-16 14:30 ` [PATCH 4.10 17/48] tracing: Add #undef to fix compile error Greg Kroah-Hartman
2017-03-16 14:30 ` [PATCH 4.10 18/48] ucount: Remove the atomicity from ucount->count Greg Kroah-Hartman
2017-03-16 14:30 ` [PATCH 4.10 19/48] efi/arm: Fix boot crash with CONFIG_CPUMASK_OFFSTACK=y Greg Kroah-Hartman
2017-03-16 14:30   ` Greg Kroah-Hartman
2017-03-16 14:30 ` [PATCH 4.10 20/48] [media] dw2102: dont do DMA on stack Greg Kroah-Hartman
2017-03-16 14:30 ` [PATCH 4.10 21/48] i2c: add missing of_node_put in i2c_mux_del_adapters Greg Kroah-Hartman
2017-03-16 14:30 ` [PATCH 4.10 22/48] powerpc: Emulation support for load/store instructions on LE Greg Kroah-Hartman
2017-03-16 14:30 ` [PATCH 4.10 23/48] powerpc/booke: Fix boot crash due to null hugepd Greg Kroah-Hartman
2017-03-16 14:30 ` [PATCH 4.10 24/48] powerpc/xics: Work around limitations of OPAL XICS priority handling Greg Kroah-Hartman
2017-03-16 14:30 ` [PATCH 4.10 25/48] PCI: Prevent VPD access for QLogic ISP2722 Greg Kroah-Hartman
2017-03-16 14:30 ` [PATCH 4.10 26/48] usb: gadget: dummy_hcd: clear usb_gadget region before registration Greg Kroah-Hartman
2017-03-16 14:30 ` [PATCH 4.10 27/48] usb: dwc3: gadget: make Set Endpoint Configuration macros safe Greg Kroah-Hartman
2017-03-16 14:30 ` [PATCH 4.10 28/48] usb: dwc3-omap: Fix missing break in dwc3_omap_set_mailbox() Greg Kroah-Hartman
2017-03-16 14:30 ` [PATCH 4.10 29/48] usb: ohci-at91: Do not drop unhandled USB suspend control requests Greg Kroah-Hartman
2017-03-16 14:30 ` [PATCH 4.10 30/48] usb: gadget: function: f_fs: pass companion descriptor along Greg Kroah-Hartman
2017-03-16 14:30 ` [PATCH 4.10 31/48] Revert "usb: gadget: uvc: Add missing call for additional setup data" Greg Kroah-Hartman
2017-03-16 14:30 ` [PATCH 4.10 32/48] usb: host: xhci-dbg: HCIVERSION should be a binary number Greg Kroah-Hartman
2017-03-16 14:30 ` [PATCH 4.10 33/48] usb: host: xhci-plat: Fix timeout on removal of hot pluggable xhci controllers Greg Kroah-Hartman
2017-03-16 14:30 ` [PATCH 4.10 34/48] USB: serial: safe_serial: fix information leak in completion handler Greg Kroah-Hartman
2017-03-16 14:30 ` [PATCH 4.10 35/48] USB: serial: omninet: fix reference leaks at open Greg Kroah-Hartman
2017-03-16 14:30 ` [PATCH 4.10 36/48] USB: iowarrior: fix NULL-deref at probe Greg Kroah-Hartman
2017-03-16 14:30 ` [PATCH 4.10 37/48] USB: iowarrior: fix NULL-deref in write Greg Kroah-Hartman
2017-03-16 14:30 ` [PATCH 4.10 38/48] USB: serial: io_ti: fix NULL-deref in interrupt callback Greg Kroah-Hartman
2017-03-16 14:30 ` [PATCH 4.10 39/48] USB: serial: io_ti: fix information leak in completion handler Greg Kroah-Hartman
2017-03-16 14:30 ` [PATCH 4.10 41/48] KVM: s390: Fix guest migration for huge guests resulting in panic Greg Kroah-Hartman
2017-03-16 14:30 ` [PATCH 4.10 42/48] KVM: arm/arm64: Let vcpu thread modify its own active state Greg Kroah-Hartman
2017-03-16 14:30 ` [PATCH 4.10 43/48] drm/i915/gvt: Fix superfluous newline in GVT_DISPLAY_READY env var Greg Kroah-Hartman
2017-03-16 14:30 ` Greg Kroah-Hartman [this message]
2017-03-16 14:30 ` [PATCH 4.10 45/48] dm: flush queued bios when process blocks to avoid deadlock Greg Kroah-Hartman
2017-03-16 14:30 ` [PATCH 4.10 46/48] [media] rc: raw decoder for keymap protocol is not loaded on register Greg Kroah-Hartman
2017-03-16 14:30 ` [PATCH 4.10 47/48] ext4: dont BUG when truncating encrypted inodes on the orphan list Greg Kroah-Hartman
2017-03-16 14:30 ` [PATCH 4.10 48/48] IB/mlx5: Verify that Q counters are supported Greg Kroah-Hartman
2017-03-16 19:21 ` [PATCH 4.10 00/48] 4.10.4-stable review Shuah Khan
2017-03-17  1:42   ` Greg Kroah-Hartman
2017-03-16 22:37 ` Guenter Roeck
2017-03-17  1:42   ` Greg Kroah-Hartman

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=20170316142922.983457516@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mchehab@s-opensource.com \
    --cc=sean@mess.org \
    --cc=stable@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.