linux-kernel.vger.kernel.org archive mirror
 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, Vladimir Zapolskiy <vz@mleia.com>,
	Linus Walleij <linus.walleij@linaro.org>
Subject: [PATCH 4.9 05/92] gpio: dont free unallocated ida on gpiochip_add_data_with_key() error path
Date: Thu, 29 Nov 2018 15:11:34 +0100	[thread overview]
Message-ID: <20181129140106.922908269@linuxfoundation.org> (raw)
In-Reply-To: <20181129140106.520639693@linuxfoundation.org>

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

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

From: Vladimir Zapolskiy <vz@mleia.com>

commit a05a14049999598a3bb6fab12db6b768a0215522 upstream.

The change corrects the error path in gpiochip_add_data_with_key()
by avoiding to call ida_simple_remove(), if ida_simple_get() returns
an error.

Note that ida_simple_remove()/ida_free() throws a BUG(), if id argument
is negative, it allows to easily check the correctness of the fix by
fuzzing the return value from ida_simple_get().

Fixes: ff2b13592299 ("gpio: make the gpiochip a real device")
Cc: stable@vger.kernel.org # v4.6+
Signed-off-by: Vladimir Zapolskiy <vz@mleia.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/gpio/gpiolib.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -1153,7 +1153,7 @@ int gpiochip_add_data(struct gpio_chip *
 	gdev->descs = kcalloc(chip->ngpio, sizeof(gdev->descs[0]), GFP_KERNEL);
 	if (!gdev->descs) {
 		status = -ENOMEM;
-		goto err_free_gdev;
+		goto err_free_ida;
 	}
 
 	if (chip->ngpio == 0) {
@@ -1285,8 +1285,9 @@ err_free_label:
 	kfree(gdev->label);
 err_free_descs:
 	kfree(gdev->descs);
-err_free_gdev:
+err_free_ida:
 	ida_simple_remove(&gpio_ida, gdev->id);
+err_free_gdev:
 	/* failures here can mean systems won't boot... */
 	pr_err("%s: GPIOs %d..%d (%s) failed to register\n", __func__,
 	       gdev->base, gdev->base + gdev->ngpio - 1,



  parent reply	other threads:[~2018-11-29 14:21 UTC|newest]

Thread overview: 102+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-29 14:11 [PATCH 4.9 00/92] 4.9.142-stable review Greg Kroah-Hartman
2018-11-29 14:11 ` [PATCH 4.9 01/92] usb: core: Fix hub port connection events lost Greg Kroah-Hartman
2018-11-29 14:11 ` [PATCH 4.9 02/92] usb: dwc3: core: Clean up ULPI device Greg Kroah-Hartman
2018-11-29 14:11 ` [PATCH 4.9 03/92] usb: xhci: fix timeout for transition from RExit to U0 Greg Kroah-Hartman
2018-11-29 14:11 ` [PATCH 4.9 04/92] MAINTAINERS: Add Sasha as a stable branch maintainer Greg Kroah-Hartman
2018-11-29 14:11 ` Greg Kroah-Hartman [this message]
2018-11-29 14:11 ` [PATCH 4.9 06/92] iwlwifi: mvm: support sta_statistics() even on older firmware Greg Kroah-Hartman
2018-11-29 14:11 ` [PATCH 4.9 07/92] iwlwifi: mvm: fix regulatory domain update when the firmware starts Greg Kroah-Hartman
2018-11-29 14:11 ` [PATCH 4.9 08/92] brcmfmac: fix reporting support for 160 MHz channels Greg Kroah-Hartman
2018-11-29 14:11 ` [PATCH 4.9 09/92] tools/power/cpupower: fix compilation with STATIC=true Greg Kroah-Hartman
2018-11-29 14:11 ` [PATCH 4.9 10/92] v9fs_dir_readdir: fix double-free on p9stat_read error Greg Kroah-Hartman
2018-11-29 14:11 ` [PATCH 4.9 11/92] selinux: Add __GFP_NOWARN to allocation at str_read() Greg Kroah-Hartman
2018-11-29 14:11 ` [PATCH 4.9 12/92] bfs: add sanity check at bfs_fill_super() Greg Kroah-Hartman
2018-11-29 14:11 ` [PATCH 4.9 13/92] sctp: clear the transport of some out_chunk_list chunks in sctp_assoc_rm_peer Greg Kroah-Hartman
2018-11-29 14:11 ` [PATCH 4.9 14/92] gfs2: Dont leave s_fs_info pointing to freed memory in init_sbd Greg Kroah-Hartman
2018-11-29 14:11 ` [PATCH 4.9 15/92] llc: do not use sk_eat_skb() Greg Kroah-Hartman
2018-11-29 14:11 ` [PATCH 4.9 16/92] mm: dont warn about large allocations for slab Greg Kroah-Hartman
2018-11-29 14:11 ` [PATCH 4.9 17/92] drm/ast: change resolution may cause screen blurred Greg Kroah-Hartman
2018-11-29 14:11 ` [PATCH 4.9 18/92] drm/ast: fixed cursor may disappear sometimes Greg Kroah-Hartman
2018-11-29 14:11 ` [PATCH 4.9 19/92] drm/ast: Remove existing framebuffers before loading driver Greg Kroah-Hartman
2018-11-29 14:11 ` [PATCH 4.9 20/92] can: dev: can_get_echo_skb(): factor out non sending code to __can_get_echo_skb() Greg Kroah-Hartman
2018-11-29 14:11 ` [PATCH 4.9 21/92] can: dev: __can_get_echo_skb(): replace struct can_frame by canfd_frame to access frame length Greg Kroah-Hartman
2018-11-29 14:11 ` [PATCH 4.9 22/92] can: dev: __can_get_echo_skb(): Dont crash the kernel if can_priv::echo_skb is accessed out of bounds Greg Kroah-Hartman
2018-11-29 14:11 ` [PATCH 4.9 23/92] can: dev: __can_get_echo_skb(): print error message, if trying to echo non existing skb Greg Kroah-Hartman
2018-11-29 14:11 ` [PATCH 4.9 24/92] ACPICA: AML interpreter: add region addresses in global list during initialization Greg Kroah-Hartman
2018-11-29 14:11 ` [PATCH 4.9 25/92] IB/core: Fix for core panic Greg Kroah-Hartman
2018-11-29 14:11 ` [PATCH 4.9 26/92] IB/hfi1: Eliminate races in the SDMA send error path Greg Kroah-Hartman
2018-11-29 14:11 ` [PATCH 4.9 27/92] usb: xhci: Prevent bus suspend if a port connect change or polling state is detected Greg Kroah-Hartman
2018-11-29 14:11 ` [PATCH 4.9 28/92] pinctrl: meson: fix pinconf bias disable Greg Kroah-Hartman
2018-11-29 14:11 ` [PATCH 4.9 29/92] KVM: PPC: Move and undef TRACE_INCLUDE_PATH/FILE Greg Kroah-Hartman
2018-11-29 14:11 ` [PATCH 4.9 30/92] cpufreq: imx6q: add return value check for voltage scale Greg Kroah-Hartman
2018-11-29 14:12 ` [PATCH 4.9 31/92] rtc: pcf2127: fix a kmemleak caused in pcf2127_i2c_gather_write Greg Kroah-Hartman
2018-11-29 14:12 ` [PATCH 4.9 32/92] floppy: fix race condition in __floppy_read_block_0() Greg Kroah-Hartman
2018-11-29 14:12 ` [PATCH 4.9 33/92] powerpc/io: Fix the IO workarounds code to work with Radix Greg Kroah-Hartman
2018-11-29 14:12 ` [PATCH 4.9 34/92] perf/x86/intel/uncore: Add more IMC PCI IDs for KabyLake and CoffeeLake CPUs Greg Kroah-Hartman
2018-11-29 14:12 ` [PATCH 4.9 35/92] ARM: make lookup_processor_type() non-__init Greg Kroah-Hartman
2018-11-29 14:12 ` [PATCH 4.9 36/92] SUNRPC: Fix a bogus get/put in generic_key_to_expire() Greg Kroah-Hartman
2018-11-29 14:12 ` [PATCH 4.9 37/92] kdb: Use strscpy with destination buffer size Greg Kroah-Hartman
2018-11-29 14:12 ` [PATCH 4.9 38/92] powerpc/numa: Suppress "VPHN is not supported" messages Greg Kroah-Hartman
2018-11-29 14:12 ` [PATCH 4.9 39/92] efi/arm: Revert deferred unmap of early memmap mapping Greg Kroah-Hartman
2018-11-29 14:28   ` Ard Biesheuvel
2018-11-29 15:02     ` Greg Kroah-Hartman
2018-11-29 15:03       ` Ard Biesheuvel
2018-11-29 14:12 ` [PATCH 4.9 40/92] tmpfs: make lseek(SEEK_DATA/SEK_HOLE) return ENXIO with a negative offset Greg Kroah-Hartman
2018-11-29 14:12 ` [PATCH 4.9 41/92] of: add helper to lookup compatible child node Greg Kroah-Hartman
2018-11-29 14:12 ` [PATCH 4.9 42/92] NFC: nfcmrvl_uart: fix OF child-node lookup Greg Kroah-Hartman
2018-11-29 14:12 ` [PATCH 4.9 43/92] net: bcmgenet: " Greg Kroah-Hartman
2018-11-29 14:12 ` [PATCH 4.9 44/92] arm64: remove no-op -p linker flag Greg Kroah-Hartman
2018-11-29 14:12 ` [PATCH 4.9 45/92] ath10k: fix kernel panic due to race in accessing arvif list Greg Kroah-Hartman
2018-11-29 14:12 ` [PATCH 4.9 46/92] Input: xpad - add product ID for Xbox One S pad Greg Kroah-Hartman
2018-11-29 14:12 ` [PATCH 4.9 47/92] Input: xpad - fix Xbox One rumble stopping after 2.5 secs Greg Kroah-Hartman
2018-11-29 14:12 ` [PATCH 4.9 48/92] Input: xpad - correctly sort vendor ids Greg Kroah-Hartman
2018-11-29 14:12 ` [PATCH 4.9 49/92] Input: xpad - move reporting xbox one home button to common function Greg Kroah-Hartman
2018-11-29 14:12 ` [PATCH 4.9 50/92] Input: xpad - simplify error condition in init_output Greg Kroah-Hartman
2018-11-29 14:12 ` [PATCH 4.9 51/92] Input: xpad - dont depend on endpoint order Greg Kroah-Hartman
2018-11-29 14:12 ` [PATCH 4.9 52/92] Input: xpad - fix stuck mode button on Xbox One S pad Greg Kroah-Hartman
2018-11-29 14:12 ` [PATCH 4.9 53/92] Input: xpad - restore LED state after device resume Greg Kroah-Hartman
2018-11-29 14:12 ` [PATCH 4.9 54/92] Input: xpad - support some quirky Xbox One pads Greg Kroah-Hartman
2018-11-29 14:12 ` [PATCH 4.9 55/92] Input: xpad - sort supported devices by USB ID Greg Kroah-Hartman
2018-11-29 14:12 ` [PATCH 4.9 56/92] Input: xpad - sync supported devices with xboxdrv Greg Kroah-Hartman
2018-11-29 14:12 ` [PATCH 4.9 57/92] Input: xpad - add USB IDs for Mad Catz Brawlstick and Razer Sabertooth Greg Kroah-Hartman
2018-11-29 14:12 ` [PATCH 4.9 58/92] Input: xpad - sync supported devices with 360Controller Greg Kroah-Hartman
2018-11-29 14:12 ` [PATCH 4.9 59/92] Input: xpad - sync supported devices with XBCD Greg Kroah-Hartman
2018-11-29 14:12 ` [PATCH 4.9 60/92] Input: xpad - constify usb_device_id Greg Kroah-Hartman
2018-11-29 14:12 ` [PATCH 4.9 61/92] Input: xpad - fix PowerA init quirk for some gamepad models Greg Kroah-Hartman
2018-11-29 14:12 ` [PATCH 4.9 62/92] Input: xpad - validate USB endpoint type during probe Greg Kroah-Hartman
2018-11-29 14:12 ` [PATCH 4.9 63/92] Input: xpad - add support for PDP Xbox One controllers Greg Kroah-Hartman
2018-11-29 14:12 ` [PATCH 4.9 64/92] Input: xpad - add PDP device id 0x02a4 Greg Kroah-Hartman
2018-11-29 14:12 ` [PATCH 4.9 65/92] Input: xpad - fix some coding style issues Greg Kroah-Hartman
2018-11-29 14:12 ` [PATCH 4.9 66/92] Input: xpad - avoid using __set_bit() for capabilities Greg Kroah-Hartman
2018-11-29 14:12 ` [PATCH 4.9 67/92] Input: xpad - add GPD Win 2 Controller USB IDs Greg Kroah-Hartman
2018-11-29 14:12 ` [PATCH 4.9 68/92] Input: xpad - fix GPD Win 2 controller name Greg Kroah-Hartman
2018-11-29 14:12 ` [PATCH 4.9 69/92] Input: xpad - add support for Xbox1 PDP Camo series gamepad Greg Kroah-Hartman
2018-11-29 14:12 ` [PATCH 4.9 70/92] cw1200: Dont leak memory if krealloc failes Greg Kroah-Hartman
2018-11-29 14:12 ` [PATCH 4.9 71/92] mwifiex: prevent register accesses after host is sleeping Greg Kroah-Hartman
2018-11-29 14:12 ` [PATCH 4.9 72/92] mwifiex: report error to PCIe for suspend failure Greg Kroah-Hartman
2018-11-29 14:12 ` [PATCH 4.9 73/92] mwifiex: Fix NULL pointer dereference in skb_dequeue() Greg Kroah-Hartman
2018-11-29 14:12 ` [PATCH 4.9 74/92] mwifiex: fix p2p device doesnt find in scan problem Greg Kroah-Hartman
2018-11-29 14:12 ` [PATCH 4.9 75/92] scsi: ufs: fix bugs related to null pointer access and array size Greg Kroah-Hartman
2018-11-29 14:12 ` [PATCH 4.9 76/92] scsi: ufshcd: Fix race between clk scaling and ungate work Greg Kroah-Hartman
2018-11-29 14:12 ` [PATCH 4.9 77/92] scsi: ufs: fix race between clock gating and devfreq scaling work Greg Kroah-Hartman
2018-11-29 14:12 ` [PATCH 4.9 78/92] scsi: ufshcd: release resources if probe fails Greg Kroah-Hartman
2018-11-29 14:12 ` [PATCH 4.9 79/92] include/linux/pfn_t.h: force ~ to be parsed as an unary operator Greg Kroah-Hartman
2018-11-29 14:12 ` [PATCH 4.9 80/92] tty: wipe buffer Greg Kroah-Hartman
2018-11-29 14:12 ` [PATCH 4.9 81/92] tty: wipe buffer if not echoing data Greg Kroah-Hartman
2018-11-29 14:12 ` [PATCH 4.9 82/92] usb: xhci: fix uninitialized completion when USB3 port got wrong status Greg Kroah-Hartman
2018-11-29 14:12 ` [PATCH 4.9 83/92] sched/core: Allow __sched_setscheduler() in interrupts when PI is not used Greg Kroah-Hartman
2018-11-29 14:12 ` [PATCH 4.9 84/92] namei: allow restricted O_CREAT of FIFOs and regular files Greg Kroah-Hartman
2018-11-29 14:12 ` [PATCH 4.9 85/92] lan78xx: Read MAC address from DT if present Greg Kroah-Hartman
2018-11-29 14:12 ` [PATCH 4.9 86/92] s390/mm: Check for valid vma before zapping in gmap_discard Greg Kroah-Hartman
2018-11-29 14:12 ` [PATCH 4.9 87/92] net: ieee802154: 6lowpan: fix frag reassembly Greg Kroah-Hartman
2018-11-29 14:12 ` [PATCH 4.9 88/92] Revert "evm: Translate user/group ids relative to s_user_ns when computing HMAC" Greg Kroah-Hartman
2018-11-29 14:12 ` [PATCH 4.9 89/92] ima: always measure and audit files in policy Greg Kroah-Hartman
2018-11-29 14:12 ` [PATCH 4.9 90/92] EVM: Add support for portable signature format Greg Kroah-Hartman
2018-11-29 14:13 ` [PATCH 4.9 91/92] ima: re-introduce own integrity cache lock Greg Kroah-Hartman
2018-11-29 14:13 ` [PATCH 4.9 92/92] ima: re-initialize iint->atomic_flags Greg Kroah-Hartman
2018-11-29 19:51 ` [PATCH 4.9 00/92] 4.9.142-stable review kernelci.org bot
2018-11-29 20:29 ` shuah
2018-11-30  7:08 ` Naresh Kamboju
2018-11-30  9:10 ` Jon Hunter
2018-11-30 10:36   ` Greg Kroah-Hartman
2018-11-30 22:28 ` Guenter Roeck

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=20181129140106.922908269@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=vz@mleia.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).