From: Sasha Levin <Alexander.Levin@microsoft.com>
To: "stable@vger.kernel.org" <stable@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Cc: Anton Vasilyev <vasilyev@ispras.ru>,
Mauro Carvalho Chehab <mchehab+samsung@kernel.org>,
Sasha Levin <Alexander.Levin@microsoft.com>
Subject: [PATCH AUTOSEL 4.14 09/89] media: davinci: vpif_display: Mix memory leak on probe error path
Date: Sun, 2 Sep 2018 13:06:19 +0000 [thread overview]
Message-ID: <20180902064918.183387-9-alexander.levin@microsoft.com> (raw)
In-Reply-To: <20180902064918.183387-1-alexander.levin@microsoft.com>
From: Anton Vasilyev <vasilyev@ispras.ru>
[ Upstream commit 61e641f36ed81ae473177c085f0bfd83ad3b55ed ]
If vpif_probe() fails on v4l2_device_register() then memory allocated
at initialize_vpif() for global vpif_obj.dev[i] become unreleased.
The patch adds deallocation of vpif_obj.dev[i] on the error path and
removes duplicated check on platform_data presence.
Found by Linux Driver Verification project (linuxtesting.org).
Signed-off-by: Anton Vasilyev <vasilyev@ispras.ru>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
drivers/media/platform/davinci/vpif_display.c | 24 ++++++++++++-------
1 file changed, 16 insertions(+), 8 deletions(-)
diff --git a/drivers/media/platform/davinci/vpif_display.c b/drivers/media/platform/davinci/vpif_display.c
index 56fe4e5b396e..4a65861433d6 100644
--- a/drivers/media/platform/davinci/vpif_display.c
+++ b/drivers/media/platform/davinci/vpif_display.c
@@ -1114,6 +1114,14 @@ static int initialize_vpif(void)
return err;
}
+static void free_vpif_objs(void)
+{
+ int i;
+
+ for (i = 0; i < VPIF_DISPLAY_MAX_DEVICES; i++)
+ kfree(vpif_obj.dev[i]);
+}
+
static int vpif_async_bound(struct v4l2_async_notifier *notifier,
struct v4l2_subdev *subdev,
struct v4l2_async_subdev *asd)
@@ -1250,11 +1258,6 @@ static __init int vpif_probe(struct platform_device *pdev)
return -EINVAL;
}
- if (!pdev->dev.platform_data) {
- dev_warn(&pdev->dev, "Missing platform data. Giving up.\n");
- return -EINVAL;
- }
-
vpif_dev = &pdev->dev;
err = initialize_vpif();
@@ -1266,7 +1269,7 @@ static __init int vpif_probe(struct platform_device *pdev)
err = v4l2_device_register(vpif_dev, &vpif_obj.v4l2_dev);
if (err) {
v4l2_err(vpif_dev->driver, "Error registering v4l2 device\n");
- return err;
+ goto vpif_free;
}
while ((res = platform_get_resource(pdev, IORESOURCE_IRQ, res_idx))) {
@@ -1309,7 +1312,10 @@ static __init int vpif_probe(struct platform_device *pdev)
if (vpif_obj.sd[i])
vpif_obj.sd[i]->grp_id = 1 << i;
}
- vpif_probe_complete();
+ err = vpif_probe_complete();
+ if (err) {
+ goto probe_subdev_out;
+ }
} else {
vpif_obj.notifier.subdevs = vpif_obj.config->asd;
vpif_obj.notifier.num_subdevs = vpif_obj.config->asd_sizes[0];
@@ -1330,6 +1336,8 @@ static __init int vpif_probe(struct platform_device *pdev)
kfree(vpif_obj.sd);
vpif_unregister:
v4l2_device_unregister(&vpif_obj.v4l2_dev);
+vpif_free:
+ free_vpif_objs();
return err;
}
@@ -1351,8 +1359,8 @@ static int vpif_remove(struct platform_device *device)
ch = vpif_obj.dev[i];
/* Unregister video device */
video_unregister_device(&ch->video_dev);
- kfree(vpif_obj.dev[i]);
}
+ free_vpif_objs();
return 0;
}
--
2.17.1
next prev parent reply other threads:[~2018-09-02 13:06 UTC|newest]
Thread overview: 92+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-02 13:06 [PATCH AUTOSEL 4.14 01/89] misc: mic: SCIF Fix scif_get_new_port() error handling Sasha Levin
2018-09-02 13:06 ` [PATCH AUTOSEL 4.14 02/89] ALSA: hda/realtek - Add mute LED quirk for HP Spectre x360 Sasha Levin
2018-09-02 13:06 ` [PATCH AUTOSEL 4.14 03/89] ethtool: Remove trailing semicolon for static inline Sasha Levin
2018-09-02 13:06 ` [PATCH AUTOSEL 4.14 04/89] i2c: aspeed: Add an explicit type casting for *get_clk_reg_val Sasha Levin
2018-09-02 13:06 ` [PATCH AUTOSEL 4.14 05/89] Bluetooth: h5: Fix missing dependency on BT_HCIUART_SERDEV Sasha Levin
2018-09-02 13:06 ` [PATCH AUTOSEL 4.14 06/89] gpio: tegra: Move driver registration to subsys_init level Sasha Levin
2018-09-02 13:06 ` [PATCH AUTOSEL 4.14 07/89] powerpc/powernv: Fix concurrency issue with npu->mmio_atsd_usage Sasha Levin
2018-09-02 13:06 ` [PATCH AUTOSEL 4.14 08/89] selftests/bpf: fix a typo in map in map test Sasha Levin
2018-09-02 13:06 ` Sasha Levin [this message]
2018-09-02 13:06 ` [PATCH AUTOSEL 4.14 10/89] media: dw2102: Fix memleak on sequence of probes Sasha Levin
2018-09-02 13:06 ` [PATCH AUTOSEL 4.14 11/89] net: phy: Fix the register offsets in Broadcom iProc mdio mux driver Sasha Levin
2018-09-02 13:06 ` [PATCH AUTOSEL 4.14 12/89] scsi: qla2xxx: Fix unintended Logout Sasha Levin
2018-09-02 13:06 ` [PATCH AUTOSEL 4.14 13/89] blk-mq: fix updating tags depth Sasha Levin
2018-09-02 13:06 ` [PATCH AUTOSEL 4.14 14/89] scsi: target: fix __transport_register_session locking Sasha Levin
2018-09-02 13:06 ` [PATCH AUTOSEL 4.14 15/89] media: usbtv: use irqsave() in USB's complete callback Sasha Levin
2018-09-02 13:06 ` [PATCH AUTOSEL 4.14 16/89] md/raid5: fix data corruption of replacements after originals dropped Sasha Levin
2018-09-02 13:06 ` [PATCH AUTOSEL 4.14 17/89] timers: Clear timer_base::must_forward_clk with timer_base::lock held Sasha Levin
2018-09-02 13:06 ` [PATCH AUTOSEL 4.14 18/89] media: camss: csid: Configure data type and decode format properly Sasha Levin
2018-09-02 13:06 ` [PATCH AUTOSEL 4.14 19/89] gpu: ipu-v3: default to id 0 on missing OF alias Sasha Levin
2018-09-02 13:06 ` [PATCH AUTOSEL 4.14 20/89] misc: ti-st: Fix memory leak in the error path of probe() Sasha Levin
2018-09-02 13:06 ` [PATCH AUTOSEL 4.14 21/89] uio: potential double frees if __uio_register_device() fails Sasha Levin
2018-09-02 13:06 ` [PATCH AUTOSEL 4.14 22/89] firmware: vpd: Fix section enabled flag on vpd_section_destroy Sasha Levin
2018-09-02 13:06 ` [PATCH AUTOSEL 4.14 23/89] Drivers: hv: vmbus: Cleanup synic memory free path Sasha Levin
2018-09-02 13:06 ` [PATCH AUTOSEL 4.14 24/89] tty: rocket: Fix possible buffer overwrite on register_PCI Sasha Levin
2018-09-02 13:06 ` [PATCH AUTOSEL 4.14 25/89] f2fs: fix to active page in lru list for read path Sasha Levin
2018-09-02 13:06 ` [PATCH AUTOSEL 4.14 26/89] ftrace: Add missing check for existing hwlat thread Sasha Levin
2018-09-02 13:06 ` [PATCH AUTOSEL 4.14 27/89] f2fs: do not set free of current section Sasha Levin
2018-09-02 13:06 ` [PATCH AUTOSEL 4.14 28/89] f2fs: fix defined but not used build warnings Sasha Levin
2018-09-02 13:06 ` [PATCH AUTOSEL 4.14 29/89] perf tools: Allow overriding MAX_NR_CPUS at compile time Sasha Levin
2018-09-02 13:06 ` [PATCH AUTOSEL 4.14 30/89] NFSv4.0 fix client reference leak in callback Sasha Levin
2018-09-02 13:06 ` [PATCH AUTOSEL 4.14 31/89] perf c2c report: Fix crash for empty browser Sasha Levin
2018-09-02 13:06 ` [PATCH AUTOSEL 4.14 32/89] fbdev/core: Disable console-lock warnings when fb.lockless_register_fb is set Sasha Levin
2018-09-02 13:06 ` [PATCH AUTOSEL 4.14 33/89] perf evlist: Fix error out while applying initial delay and LBR Sasha Levin
2018-09-02 13:06 ` [PATCH AUTOSEL 4.14 34/89] macintosh/via-pmu: Add missing mmio accessors Sasha Levin
2018-09-02 13:06 ` [PATCH AUTOSEL 4.14 35/89] ath9k: report tx status on EOSP Sasha Levin
2018-09-02 13:06 ` [PATCH AUTOSEL 4.14 36/89] ath9k_hw: fix channel maximum power level test Sasha Levin
2018-09-02 13:06 ` [PATCH AUTOSEL 4.14 37/89] ath10k: prevent active scans on potential unusable channels Sasha Levin
2018-09-02 13:06 ` [PATCH AUTOSEL 4.14 38/89] wlcore: Set rx_status boottime_ns field on rx Sasha Levin
2018-09-02 13:06 ` [PATCH AUTOSEL 4.14 39/89] rpmsg: core: add support to power domains for devices Sasha Levin
2018-09-02 13:06 ` [PATCH AUTOSEL 4.14 40/89] MIPS: Fix ISA virt/bus conversion for non-zero PHYS_OFFSET Sasha Levin
2018-09-02 13:06 ` [PATCH AUTOSEL 4.14 41/89] ata: libahci: Allow reconfigure of DEVSLP register Sasha Levin
2018-09-02 13:06 ` [PATCH AUTOSEL 4.14 42/89] ata: libahci: Correct setting " Sasha Levin
2018-09-02 13:06 ` [PATCH AUTOSEL 4.14 43/89] scsi: 3ware: fix return 0 on the error path of probe Sasha Levin
2018-09-02 13:07 ` [PATCH AUTOSEL 4.14 44/89] tools/testing/nvdimm: kaddr and pfn can be NULL to ->direct_access() Sasha Levin
2018-09-02 13:07 ` [PATCH AUTOSEL 4.14 45/89] ath10k: disable bundle mgmt tx completion event support Sasha Levin
2018-09-02 13:07 ` [PATCH AUTOSEL 4.14 46/89] Bluetooth: hidp: Fix handling of strncpy for hid->name information Sasha Levin
2018-09-02 13:07 ` [PATCH AUTOSEL 4.14 47/89] x86/mm: Remove in_nmi() warning from vmalloc_fault() Sasha Levin
2018-09-02 13:07 ` [PATCH AUTOSEL 4.14 48/89] x86/kexec: Allocate 8k PGDs for PTI Sasha Levin
2018-09-02 13:07 ` [PATCH AUTOSEL 4.14 49/89] ARM: 8783/1: NOMMU: Extend check for VBAR support Sasha Levin
2018-09-10 9:42 ` Vladimir Murzin
2018-09-10 14:12 ` Sasha Levin
2018-09-12 17:31 ` Sasha Levin
2018-09-02 13:07 ` [PATCH AUTOSEL 4.14 50/89] pinctrl: imx: off by one in imx_pinconf_group_dbg_show() Sasha Levin
2018-09-02 13:07 ` [PATCH AUTOSEL 4.14 51/89] gpio: ml-ioh: Fix buffer underwrite on probe error path Sasha Levin
2018-09-02 13:07 ` [PATCH AUTOSEL 4.14 52/89] pinctrl/amd: only handle irq if it is pending and unmasked Sasha Levin
2018-09-02 13:07 ` [PATCH AUTOSEL 4.14 53/89] net: mvneta: fix mtu change on port without link Sasha Levin
2018-09-02 13:07 ` [PATCH AUTOSEL 4.14 54/89] f2fs: try grabbing node page lock aggressively in sync scenario Sasha Levin
2018-09-02 13:07 ` [PATCH AUTOSEL 4.14 55/89] pktcdvd: Fix possible Spectre-v1 for pkt_devs Sasha Levin
2018-09-02 13:07 ` [PATCH AUTOSEL 4.14 56/89] f2fs: fix to skip GC if type in SSA and SIT is inconsistent Sasha Levin
2018-09-02 13:07 ` [PATCH AUTOSEL 4.14 57/89] tpm_tis_spi: Pass the SPI IRQ down to the driver Sasha Levin
2018-09-02 13:07 ` [PATCH AUTOSEL 4.14 58/89] tpm/tpm_i2c_infineon: switch to i2c_lock_bus(..., I2C_LOCK_SEGMENT) Sasha Levin
2018-09-02 13:07 ` [PATCH AUTOSEL 4.14 59/89] f2fs: fix to do sanity check with reserved blkaddr of inline inode Sasha Levin
2018-09-02 13:07 ` [PATCH AUTOSEL 4.14 60/89] MIPS: Octeon: add missing of_node_put() Sasha Levin
2018-09-02 13:07 ` [PATCH AUTOSEL 4.14 61/89] MIPS: generic: fix " Sasha Levin
2018-09-02 13:07 ` [PATCH AUTOSEL 4.14 62/89] iio: ad9523: Fix return value for ad952x_store() Sasha Levin
2018-09-02 13:07 ` [PATCH AUTOSEL 4.14 63/89] net: dcb: For wild-card lookups, use priority -1, not 0 Sasha Levin
2018-09-02 13:07 ` [PATCH AUTOSEL 4.14 64/89] dm cache: only allow a single io_mode cache feature to be requested Sasha Levin
2018-09-02 13:07 ` [PATCH AUTOSEL 4.14 65/89] Input: atmel_mxt_ts - only use first T9 instance Sasha Levin
2018-09-02 13:07 ` [PATCH AUTOSEL 4.14 66/89] iommu/dma: Respect bus DMA limit for IOVAs Sasha Levin
2018-09-02 13:07 ` [PATCH AUTOSEL 4.14 67/89] media: s5p-mfc: Fix buffer look up in s5p_mfc_handle_frame_{new, copy_time} functions Sasha Levin
2018-09-02 13:07 ` [PATCH AUTOSEL 4.14 68/89] partitions/aix: append null character to print data from disk Sasha Levin
2018-09-02 13:07 ` [PATCH AUTOSEL 4.14 69/89] partitions/aix: fix usage of uninitialized lv_info and lvname structures Sasha Levin
2018-09-02 13:07 ` [PATCH AUTOSEL 4.14 70/89] media: helene: fix xtal frequency setting at power on Sasha Levin
2018-09-02 13:07 ` [PATCH AUTOSEL 4.14 71/89] f2fs: fix to wait on page writeback before updating page Sasha Levin
2018-09-02 13:07 ` [PATCH AUTOSEL 4.14 72/89] f2fs: Fix uninitialized return in f2fs_ioc_shutdown() Sasha Levin
2018-09-02 13:07 ` [PATCH AUTOSEL 4.14 73/89] media: em28xx: Fix DualHD disconnect oops Sasha Levin
2018-09-02 13:07 ` [PATCH AUTOSEL 4.14 74/89] iommu/ipmmu-vmsa: Fix allocation in atomic context Sasha Levin
2018-09-02 13:07 ` [PATCH AUTOSEL 4.14 75/89] mfd: ti_am335x_tscadc: Fix struct clk memory leak Sasha Levin
2018-09-02 13:07 ` [PATCH AUTOSEL 4.14 76/89] f2fs: fix to do sanity check with {sit,nat}_ver_bitmap_bytesize Sasha Levin
2018-09-02 13:07 ` [PATCH AUTOSEL 4.14 77/89] ALSA: riptide: Properly endian notations Sasha Levin
2018-09-02 13:07 ` [PATCH AUTOSEL 4.14 78/89] ALSA: pcm: Fix sparse warning wrt PCM format type Sasha Levin
2018-09-02 13:07 ` [PATCH AUTOSEL 4.14 79/89] ALSA: wss: " Sasha Levin
2018-09-02 13:07 ` [PATCH AUTOSEL 4.14 80/89] ALSA: sb: Fix PCM format bit calculation Sasha Levin
2018-09-02 13:07 ` [PATCH AUTOSEL 4.14 81/89] ALSA: asihpi: Fix PCM format notations Sasha Levin
2018-09-02 13:07 ` [PATCH AUTOSEL 4.14 82/89] ALSA: ad1816a: Fix sparse warning wrt PCM format type Sasha Levin
2018-09-02 13:07 ` [PATCH AUTOSEL 4.14 83/89] ALSA: hda: Fix implicit PCM format type conversion Sasha Levin
2018-09-02 13:07 ` [PATCH AUTOSEL 4.14 84/89] ALSA: au88x0: Fix sparse warning wrt PCM format type Sasha Levin
2018-09-02 13:07 ` [PATCH AUTOSEL 4.14 85/89] ALSA: sb: " Sasha Levin
2018-09-02 13:07 ` [PATCH AUTOSEL 4.14 86/89] NFSv4.1: Fix a potential layoutget/layoutrecall deadlock Sasha Levin
2018-09-02 13:08 ` [PATCH AUTOSEL 4.14 87/89] MIPS: WARN_ON invalid DMA cache maintenance, not BUG_ON Sasha Levin
2018-09-02 13:08 ` [PATCH AUTOSEL 4.14 88/89] RDMA/cma: Do not ignore net namespace for unbound cm_id Sasha Levin
2018-09-02 13:08 ` [PATCH AUTOSEL 4.14 89/89] fuse: Add missed unlock_page() to fuse_readpages_fill() 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=20180902064918.183387-9-alexander.levin@microsoft.com \
--to=alexander.levin@microsoft.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mchehab+samsung@kernel.org \
--cc=stable@vger.kernel.org \
--cc=vasilyev@ispras.ru \
/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
Powered by JetHome