From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8645139FE3; Fri, 24 Nov 2023 18:00:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="DoDIruWP" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1290AC433C7; Fri, 24 Nov 2023 18:00:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1700848845; bh=h81QsO7TMJ9bzKYcKq+vg3muVhiUOTwZVELYLT70GSk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DoDIruWPgtzL4xu1bYMBRrRAeB8G0daGIXSyYWagtMVozEeAifCepZoy7INuRUkI4 iLC3Cin0CIzvTWEghul9hici7Y4YWW55lOF5MG5dkCTD0MTMUeZx/xhrpePS6DP4Dg bNdD+Ff7FHMZ009GYR8Ia9pu0BYjH1HQtiMtLp0g= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, stable , Jose Javier Rodriguez Barbarin , Jorge Sanjuan Garcia Subject: [PATCH 4.19 67/97] mcb: fix error handling for different scenarios when parsing Date: Fri, 24 Nov 2023 17:50:40 +0000 Message-ID: <20231124171936.638933322@linuxfoundation.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231124171934.122298957@linuxfoundation.org> References: <20231124171934.122298957@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Sanjuán García, Jorge commit 63ba2d07b4be72b94216d20561f43e1150b25d98 upstream. chameleon_parse_gdd() may fail for different reasons and end up in the err tag. Make sure we at least always free the mcb_device allocated with mcb_alloc_dev(). If mcb_device_register() fails, make sure to give up the reference in the same place the device was added. Fixes: 728ac3389296 ("mcb: mcb-parse: fix error handing in chameleon_parse_gdd()") Cc: stable Reviewed-by: Jose Javier Rodriguez Barbarin Signed-off-by: Jorge Sanjuan Garcia Link: https://lore.kernel.org/r/20231019141434.57971-2-jorge.sanjuangarcia@duagon.com Signed-off-by: Greg Kroah-Hartman --- drivers/mcb/mcb-core.c | 1 + drivers/mcb/mcb-parse.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) --- a/drivers/mcb/mcb-core.c +++ b/drivers/mcb/mcb-core.c @@ -251,6 +251,7 @@ int mcb_device_register(struct mcb_bus * return 0; out: + put_device(&dev->dev); return ret; } --- a/drivers/mcb/mcb-parse.c +++ b/drivers/mcb/mcb-parse.c @@ -105,7 +105,7 @@ static int chameleon_parse_gdd(struct mc return 0; err: - put_device(&mdev->dev); + mcb_free_dev(mdev); return ret; }