From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3D54CC43603 for ; Mon, 16 Dec 2019 18:47:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0813B2082E for ; Mon, 16 Dec 2019 18:47:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1576522022; bh=YEsL8fnV5oRLJ3Z306dsBmpxsyykbyKz9/Cdu3UFYAE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=ZOViP54aIU47UiUgvnlVh895Ibpu7dS95l1aer5oW5deK23gJc59RxFXkEihhqbnz DTiAjTqYu7Q7dYlB84yV4U3nw6xGYm0iGsF3E+ABrYGNkys1kYAoVjUoVbSxQ413ly zMfpV8EwkAS/CC0Y/uvn8S0dIbugQd87zwwjwAe0= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728179AbfLPSrA (ORCPT ); Mon, 16 Dec 2019 13:47:00 -0500 Received: from mail.kernel.org ([198.145.29.99]:53274 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727916AbfLPRzr (ORCPT ); Mon, 16 Dec 2019 12:55:47 -0500 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 92EDA205ED; Mon, 16 Dec 2019 17:55:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1576518947; bh=YEsL8fnV5oRLJ3Z306dsBmpxsyykbyKz9/Cdu3UFYAE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fewTPw0KpdVK8OvjEtsmbnh+MEI6yYTs6xBqt2w+MuHaNDU8f9fdoJvAISW76FxxZ KeWeNaZBRXZb3kE3lRJjkm4U5otxD23CJ38ucWUscJk5ghJP5pYJWR7PQLlelLqSs9 D5dH9Wbru2w5ryoO6l07LCHoTu6Jie+MUIW5lWKI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, emamd001@umn.edu, Navid Emamdoost , Dmitry Torokhov Subject: [PATCH 4.14 131/267] Input: Fix memory leak in psxpad_spi_probe Date: Mon, 16 Dec 2019 18:47:37 +0100 Message-Id: <20191216174906.886764514@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191216174848.701533383@linuxfoundation.org> References: <20191216174848.701533383@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 From: Navid Emamdoost In the implementation of psxpad_spi_probe() the allocated memory for pdev is leaked if psxpad_spi_init_ff() or input_register_polled_device() fail. The solution is using device managed allocation, like the one used for pad. Perform the allocation using devm_input_allocate_polled_device(). Fixes: 8be193c7b1f4 ("Input: add support for PlayStation 1/2 joypads connected via SPI") Signed-off-by: Navid Emamdoost Acked-by: Dmitry Torokhov Signed-off-by: Greg Kroah-Hartman --- drivers/input/joystick/psxpad-spi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/input/joystick/psxpad-spi.c +++ b/drivers/input/joystick/psxpad-spi.c @@ -292,7 +292,7 @@ static int psxpad_spi_probe(struct spi_d if (!pad) return -ENOMEM; - pdev = input_allocate_polled_device(); + pdev = devm_input_allocate_polled_device(&spi->dev); if (!pdev) { dev_err(&spi->dev, "failed to allocate input device\n"); return -ENOMEM;