From patchwork Fri Mar 1 14:07:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Elfring X-Patchwork-Id: 777279 Received: from mout.web.de (mout.web.de [212.227.15.3]) (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 D08A96D1A4; Fri, 1 Mar 2024 14:08:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=212.227.15.3 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709302085; cv=none; b=IyXMf/1M7J0AeOLMwbbX7WRj3YEzUp7fhD0tSslI68PrRGjbFhTD8eD3hBMGaWclIfhnQCbS1FNFe4jK4hzstfyDhwGIAiyQpxnJYIAz9LHZ2FzdDT0zvi8t+B9V4bAVvU88HbNKUyfFXSiwhhLMiT6pb9sYQKBt+xs6efItGVU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709302085; c=relaxed/simple; bh=bCnomT+2ED4Jkxxq+pu6nRP6pi+vAEgaQ1rqoBBay6g=; h=Message-ID:Date:MIME-Version:To:Cc:From:Subject:Content-Type; b=QLY0X4OojeClxVPGfg/E+wCgiARYMQs+TqG5z0T0STbkfhzhB33Yrt8MpIkJ0OAE8t3+Wnj7cNbQZHjcjfqUvXQ3UP2pGDXmiy9iFVQCphv2zkFiDUiCPc0H62V3QpdxYFKcwDMeGKR1jYmaTcU+zAtpZ6JCFtCIVitfYWoCssk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=web.de; spf=pass smtp.mailfrom=web.de; dkim=pass (2048-bit key) header.d=web.de header.i=markus.elfring@web.de header.b=IqosRX5u; arc=none smtp.client-ip=212.227.15.3 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=web.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=web.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=web.de header.i=markus.elfring@web.de header.b="IqosRX5u" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=s29768273; t=1709302072; x=1709906872; i=markus.elfring@web.de; bh=bCnomT+2ED4Jkxxq+pu6nRP6pi+vAEgaQ1rqoBBay6g=; h=X-UI-Sender-Class:Date:To:Cc:From:Subject; b=IqosRX5up0YUpcgwldV00Fw7nQDhh3bvWhQ+GfxDrLjI+idbP/2SFIK55bVAEQQu GinRhCCqSmKUtQFeZaF4QaSpsy1CJzWIB0bvEM7fA91KFkRpMONncM3pAHqdOq3Dr T/J2ulB4FlRDRUJxaNZCtu1SqDHzyD7ygd0GGTC75Yuk4fTgbniRD9JR2qibmM7eH tfre5vDgyUqOj3avidDuy6NBb7QZc+wF6G2XmKCBWm2iDIUOyCYyWeJaX8BsU+SDT RCDCVmsN8wbM8y6jdeEI/Ih2NkHqhOaAzx7fZJHzxJMd/Iceis6Ebgugti0UFZ+py xiir5cRN/EoT/68dDQ== X-UI-Sender-Class: 814a7b36-bfc1-4dae-8640-3722d8ec6cd6 Received: from [192.168.178.21] ([94.31.86.95]) by smtp.web.de (mrweb006 [213.165.67.108]) with ESMTPSA (Nemesis) id 1N8Voj-1qkMRq3it7-014X8n; Fri, 01 Mar 2024 15:07:51 +0100 Message-ID: <9d0511cd-1fb2-4612-9b21-196a43ad0397@web.de> Date: Fri, 1 Mar 2024 15:07:50 +0100 Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird To: linux-media@vger.kernel.org, kernel-janitors@vger.kernel.org, Mauro Carvalho Chehab , Sakari Ailus Content-Language: en-GB Cc: LKML From: Markus Elfring Subject: [PATCH] media: v4l2-fwnode: Improve exception handling in v4l2_fwnode_connector_add_link()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FFmTnxNyvyctVEdT0s7dkfD1e3GDBU5S5hs/msJTg LkEuGY0/6SC1phYZIqeHLy05gcupVQCKfV3IuRwmxFG0M= From: Markus Elfring Date: Fri, 1 Mar 2024 15:02:09 +0100 The kfree() function was called in one case by the v4l2_fwnode_connector_add_link() function during error handling even if the passed variable contained a null pointer. Thus use another label. Signed-off-by: Markus Elfring --- drivers/media/v4l2-core/v4l2-fwnode.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -- 2.44.0 diff --git a/drivers/media/v4l2-core/v4l2-fwnode.c b/drivers/media/v4l2-core/v4l2-fwnode.c index 89c7192148df..dc6daf3a9a51 100644 --- a/drivers/media/v4l2-core/v4l2-fwnode.c +++ b/drivers/media/v4l2-core/v4l2-fwnode.c @@ -744,7 +744,7 @@ int v4l2_fwnode_connector_add_link(struct fwnode_handle *fwnode, link = kzalloc(sizeof(*link), GFP_KERNEL); if (!link) { err = -ENOMEM; - goto err; + goto put_fwnode_ep; } err = v4l2_fwnode_parse_link(connector_ep, &link->fwnode_link); @@ -760,6 +760,7 @@ int v4l2_fwnode_connector_add_link(struct fwnode_handle *fwnode, err: kfree(link); +put_fwnode_ep: fwnode_handle_put(connector_ep); return err;