From patchwork Wed Sep 25 08:10:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Elfring X-Patchwork-Id: 830723 Received: from mout.web.de (mout.web.de [217.72.192.78]) (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 52F08158D81; Wed, 25 Sep 2024 08:11:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.72.192.78 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727251865; cv=none; b=PvfWC1oDVt6XAoYxALUo6nGQDevYP1ZIsKc4DryIAND1wSRMF3OEUSOUtiZdtmfhVnLHS+qyWriP5Z11/KY1UaZhUAyNG7QlZZ2g0JAH+qENgIr0fYNnys9vUhuv6iyzp1qgWmSkGQ0mTt35Mekz/JTpnPlCdSXDhCVCuo8Uy2Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727251865; c=relaxed/simple; bh=HHl6WwQYUAJzme6Y7IXjUEQOFRMq2SoZg+WywkKQlFA=; h=Message-ID:Date:MIME-Version:To:Cc:From:Subject:Content-Type; b=eLhP5xe9g03h3Id2ySe/WKqS4W8//5Zyw+yRo/0qWoSzIc9QwitO+ybu8WHTm4kZmMG2MR9gh9WzaJm3oTY+4VlIaYuohuFAYB1glz53NqB2V5JGVS6rPHT1NwKhlYD+XUDRXtd38AszVbhHpw9LLWmq0JMcomC8nwpObFab+Ik= 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=kC9oMuRO; arc=none smtp.client-ip=217.72.192.78 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="kC9oMuRO" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=web.de; s=s29768273; t=1727251853; x=1727856653; i=markus.elfring@web.de; bh=FyrBvkfHDOPr+nJ141V43deKyMB0B1N9ZJUIyJ8uv54=; h=X-UI-Sender-Class:Message-ID:Date:MIME-Version:To:Cc:From: Subject:Content-Type:Content-Transfer-Encoding:cc: content-transfer-encoding:content-type:date:from:message-id: mime-version:reply-to:subject:to; b=kC9oMuROGFHVTUphVd6xslEaU5jf04jxtxY/sxLlwZtOC1ESI75PW1M7zaNb/bIy rRCgPw+aDOTBa6i5h3GxUgq7PSmpVQ3LOM2/KVBeL5jL1RTBWAp/ZbVOI5cHsV5k5 HLvsnUHbD3HNRbaUlSyY/oPV0njI7KJ0Q7BHPTrvIu6GK1folvqSBucIgRsHY7snk 6ueoGd7LT611qPpcpp4QZSEWgUnUVR7BFjnSrrEXzWC5Ogr8pESiSSPu4dGxtlKrX 9P+TZVv9htOgWH7FCdLxAa+J1LF0IzUp2ufM5FS0EhNu707AAZuHfDXJqQdHbgVlj u592N1v2Ka5L+H2Q7w== X-UI-Sender-Class: 814a7b36-bfc1-4dae-8640-3722d8ec6cd6 Received: from [192.168.178.21] ([94.31.84.95]) by smtp.web.de (mrweb105 [213.165.67.124]) with ESMTPSA (Nemesis) id 1MhWor-1sEpV008IN-00hMeu; Wed, 25 Sep 2024 10:10:53 +0200 Message-ID: <26b7f215-4f83-413c-9dab-737d790053c0@web.de> Date: Wed, 25 Sep 2024 10:10:38 +0200 Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird To: linux-usb@vger.kernel.org, Andreas Noever , Michael Jamet , Mika Westerberg , Yehezkel Bernat Content-Language: en-GB Cc: LKML , kernel-janitors@vger.kernel.org From: Markus Elfring Subject: [PATCH] thunderbolt: Use common error handling code in update_property_block() X-Provags-ID: V03:K1:Tm+byGEofqsYi7XmFVHVNPrI5zFcxZ1pLwSuSiEN0mLcD76JOBv 1Ynakketst6oCHRgmz/tjBGJUYOl6LIlDavzH98OtFxVER4aG80sFy5jBkzLuY8OVleH1ol vay0a9O35SvpYkOcz4NjOB/NVpxsrBO97mfkhhVzRo29q0egbteBEztK63M+ghIayzgB+w8 VqVcAS4KCrkDQkbI+mw7g== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:NXP+3rDlkqA=;XYH5Kyk8OxO3UnZF/yMVHnSj5AM oyfd2nS8t2uzXDRo9rCd8xZBaZu6RoNtJhanopwN9E/0jKEYxEdBxFwcwFxAWgpa2A1YgDu/5 ORdbvx+pyvjTV9PPw55iB8OVQw5LcNwx9O2dtWX7qHQzdHrO3coUP1RM3k2x/lR51ucRrCXWI rj34e6IRtYTrn01C53IrmqniuWp26AQ7T2NjVDsUC1OTkiOpnNXk1mFh9eOzXdwo3S37SjdIl yJUfFaDV3S1AG8LaYRxe0jN567vMDXAKN3Zo8t3sec61N7ohHRRKz8plG7T1pH3R0RniySUSw JqMvxVdEnP/A2LHI5z+csX8A/BYlG1uKNHpXOtRNtwiu+aSdo871Qrpx9tj+O3exXikisJEHM Wkg6xfqIiE4moIf05+3e5Y4uCiPLLAig03hGeOi5ELtUJehDTwl6+wJb//3V5y+Qarnyu3YEt R3herD6uJGtoWtzWDvd69RbOoFlZI5Py3iC094Yy1kS8ydjCnzhcCK7u9cskMbQFZt5bsN+R7 TBiy0yOUyK5ynVNQzcOgTm7JwZobfnecZeMOaaChqyrvWicSY9HvLqsmXxAPopgS6mwlUa6yR koyD3u28MJRMoz6zkrdMab1xUJVUKUzM8BonOjabiLf4T5+zilijp+C1X1RHWv8cLCoAWcNed 3oFGIc2fM78N9q+I70YzxODrAWydTMRctW/DOhKztI/lBCGPUfcOycAr/7rdFMPylAw8aD29S ne96Y387OGlImf9+OT9IGwdR6nU0QHPb3P2TFepw6JX91H9iB4o497OGe/GeelG62ahD5nSFO iJ9HTc1iVNkoIuM/0dnS6DgA== From: Markus Elfring Date: Wed, 25 Sep 2024 09:39:16 +0200 Add a jump target so that a bit of exception handling can be better reused at the end of this function implementation. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring --- drivers/thunderbolt/xdomain.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) -- 2.46.1 diff --git a/drivers/thunderbolt/xdomain.c b/drivers/thunderbolt/xdomain.c index 11a50c86a1e4..8e3cf95ca99c 100644 --- a/drivers/thunderbolt/xdomain.c +++ b/drivers/thunderbolt/xdomain.c @@ -670,23 +670,19 @@ static void update_property_block(struct tb_xdomain *xd) ret = tb_property_format_dir(dir, NULL, 0); if (ret < 0) { dev_warn(&xd->dev, "local property block creation failed\n"); - tb_property_free_dir(dir); - goto out_unlock; + goto out_free_dir; } block_len = ret; block = kcalloc(block_len, sizeof(*block), GFP_KERNEL); - if (!block) { - tb_property_free_dir(dir); - goto out_unlock; - } + if (!block) + goto out_free_dir; ret = tb_property_format_dir(dir, block, block_len); if (ret) { dev_warn(&xd->dev, "property block generation failed\n"); - tb_property_free_dir(dir); kfree(block); - goto out_unlock; + goto out_free_dir; } tb_property_free_dir(dir); @@ -701,6 +697,11 @@ static void update_property_block(struct tb_xdomain *xd) out_unlock: mutex_unlock(&xd->lock); mutex_unlock(&xdomain_lock); + return; + +out_free_dir: + tb_property_free_dir(dir); + goto out_unlock; } static void start_handshake(struct tb_xdomain *xd)