Received: by 2002:ab2:7b86:0:b0:1f7:5705:b850 with SMTP id q6csp783196lqh; Sun, 5 May 2024 01:39:29 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVwGdxmlGjVaHNJc7BUbVA4TLbwWd5yRV/8P1gRz37q53o+kxlr1CnwCPToKTv/tTXxXhoGM4WVw76Rk+BNIJ2EmSUHuXxEcFqx5dD3Tg== X-Google-Smtp-Source: AGHT+IFa1l58NJ7o1A8SMWGyqLgtkXWcKt+SEE32cDUUtTcoM8vJ712dTYvz/yhZepIUrb0kdy8y X-Received: by 2002:a05:6a21:6704:b0:1af:a469:75aa with SMTP id wh4-20020a056a21670400b001afa46975aamr1622664pzb.46.1714898369164; Sun, 05 May 2024 01:39:29 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714898369; cv=pass; d=google.com; s=arc-20160816; b=ZexX+JLb+D0oaL5zctkYtxn/inpSUZlPTZx4oEPhYGPNGJUsPQWP3sOzPEwTWn6h7+ L+yZlINlRrBTUUiO5yOQtULGEwsTrfaSEnO7Pinw+/N7FU46FTwfCz4MqyxaURmtUroZ 06Lco1FA2eluPfHF9Cjx11EdjBbeV1kLCgg9MnUQ8L/VaJalZEH8ypmNbJMs8GeUW3UE MWIxTRX70neRD7LJNSaOl46Epi7h5OpXmqplTDeJLiGg2rprMl7uFlEe443g7g7Ny8HM +p+Vq3Dco/NFdtHhG0lhZKFZddBPEtLRGtb9xu1j6STXu6wgO3EOveLOKFIAoCqGpOQB 4cXQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=ui-outboundreport:content-transfer-encoding:subject:from:cc :content-language:to:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=Hmm67Eh9H6ov9LhnYrM6BTLWBoQqSoIzaLVwbXrd8B4=; fh=KkLr2PARN0e+0XUIGQpIoXDB/+3ql4JmH6k3lGZKRVg=; b=TgpTVfgS9Km3//mogcW1snSZHtspZTbjgEw6JyREDfT/xXkF5s8tIpcJVToIzecExv 5YwR6VTudI2yzQBPOfVk0cgHX0aX2fLI4VKDA2JMcJlfLsC+RiF7e1m4awbbvuvh7oYO yiEI9H57VsG83o4+o3EJD/Rauaec6ORh9DSoAlpSSe0n2h/ZoVFNSWJ/wF1lOHIVbI6p kfpZ8ZoGjNdMdd6IX1SI9vV+dh4GLifB4ITKbwVG63cSduNlyC7EdUUGMnJMLuZQpXTX L5zWsf8oLrxrbXzKxtkSpLqdijJWEu7QlsSj1LZP1mjPdeh33giQPpHvbkxhQsj/Faq4 KlPQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@web.de header.s=s29768273 header.b=BRcJ5W2V; arc=pass (i=1 spf=pass spfdomain=web.de dkim=pass dkdomain=web.de dmarc=pass fromdomain=web.de); spf=pass (google.com: domain of linux-bluetooth+bounces-4314-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-4314-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=web.de Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id lv4-20020a1709032a8400b001e8505652aasi6442705plb.46.2024.05.05.01.39.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 May 2024 01:39:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth+bounces-4314-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@web.de header.s=s29768273 header.b=BRcJ5W2V; arc=pass (i=1 spf=pass spfdomain=web.de dkim=pass dkdomain=web.de dmarc=pass fromdomain=web.de); spf=pass (google.com: domain of linux-bluetooth+bounces-4314-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-4314-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=web.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id B6B77281BBE for ; Sun, 5 May 2024 08:39:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5AFBB6FD3; Sun, 5 May 2024 08:39:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=web.de header.i=markus.elfring@web.de header.b="BRcJ5W2V" X-Original-To: linux-bluetooth@vger.kernel.org Received: from mout.web.de (mout.web.de [212.227.17.12]) (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 57BD02582; Sun, 5 May 2024 08:39:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=212.227.17.12 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714898359; cv=none; b=CgDKd7gf/QRFMDslUn1wtiJXAy8HjBD4XicDaP1f5taUmO3JxknhQrydm/y1dNxxhH0v54PUrGdHS/0q9wyHNjtl9QX4mKcWNauzOWRD9nhGK1B6xJidC+unKk+P6AiGL0av3XPm0OuG6/lkyD0vz3ai1K48EyIT0CS3+syG0mM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714898359; c=relaxed/simple; bh=n1mdYuAeP4uvVo+sfymUmrxvP4vV2KCkX9GBScpWDHI=; h=Message-ID:Date:MIME-Version:To:Cc:From:Subject:Content-Type; b=YbTTs0xCPgGa4jZUI6FoqpWnoALqN8jqzR6LhRP6tj646GN9eBsarYqqg63xuTsop2+Y7MGRDT/uPEpblYhecafZOECpDW+/PjGFlhz0VRz0d5Vr774KA2F65kIasOVQMBMHyX+zIWACsk6VhN5A0NvLPCGUh0THGHKZG2rU6Qw= 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=BRcJ5W2V; arc=none smtp.client-ip=212.227.17.12 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=web.de; s=s29768273; t=1714898354; x=1715503154; i=markus.elfring@web.de; bh=Hmm67Eh9H6ov9LhnYrM6BTLWBoQqSoIzaLVwbXrd8B4=; 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=BRcJ5W2VVGsmgIoCIqI+Sk56PveDllTGg6KYSfsK0Sjh8n9GzjNm6izFXHw3ldm2 qV1eh/ZajNfQxYr8WIohMa1kdJjLGLkGX2y6RzBml7IOj5T69e3uhYR2WrVKMXW7j v4hjMlwBx8er3YA3Qsmw7gBPXzrw5fbYF6cG4yv57GprhbeBFpGPJZZuelz8H18ap JtoGDb7ZFHQvIKDLBfmah1g+CGOjn3mMKvqLtHIQ8w2qDagLQmVYOn3udzF3zPoUj zu9xUJLoSVZG/M7FJ68IWWv6dQkUnq4yaZP+0Whh6y0uxt9HOXS8ouyyPGM+VX8pl 1JUZUV4dgrhuAbddPw== X-UI-Sender-Class: 814a7b36-bfc1-4dae-8640-3722d8ec6cd6 Received: from [192.168.178.21] ([94.31.83.95]) by smtp.web.de (mrweb105 [213.165.67.124]) with ESMTPSA (Nemesis) id 1MidHZ-1sWYtB1hGJ-00e3zy; Sun, 05 May 2024 10:39:14 +0200 Message-ID: Date: Sun, 5 May 2024 10:39:02 +0200 Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird To: linux-bluetooth@vger.kernel.org, kernel-janitors@vger.kernel.org, Luiz Augusto von Dentz , Marcel Holtmann Content-Language: en-GB Cc: LKML From: Markus Elfring Subject: [PATCH] Bluetooth: qca: Use common error handling code in two functions Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:0iNeMSH+GmRX8I7zfctCspvLyk3Uw/CSkBS/P8/9bpnr0uZPK7G IAuxQmB4gsT+bMhVjantpvy4PWwtw1mNl/qDSbFYsIhYe5HWMOS6JBm2PF976kKDWuvoJMC y7qOa0bdmKP1D2+gWyggCoSB7HxwpOg+UOqrHut1WhB7wDacSXoeemwdIkIfkrJd4yIumEK yVHb38r0ZgVg/RjrsGzJA== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:gKFNHLjIIng=;aQeYxwQH4dG1wm0nev68l75Rw38 6dr1zAuiXC1aLQHo3R7uoCUMWJzyiIkLcTtlVGUUuGaEvf33EXIcQgqQJrPBmT92DGgvVMp6e 7mI/kh+KKPe3cl2HxbgjW4hEmoS56kOiYpULZ9/A08bRA4dHz+DxmHe2h5qrsmdUClHSlOZ54 aMXul2ictR7RA33doJv/5rwz9jXmA/ONdg4rFgB121sAFXoefLsESYEpaBVC2wVXmP+I59WAL RgmGzoMwQqPht9yyBO6wd13FlPY3jQnbBKm4axjzzrRPAk9MgbQd5+c3oF6bKf4A3+aO67Ucc 3B7zsgy7fqAg8xug0zrPYNiTRl0IOndnDd2hO8c10cq/7J3gmvfbFTOtIDGXV++vhkP/0moTW ptgNtJwzSQk1WZuyYvQ6QWA5SIWDAvm76SdXu/uOiS0swXTwNVoCRCj88NntrkJV91PGm/6r+ AFD4wTHKHRMu/DLtI0YgSdCfo4LVBm+1sDMVXMpCQoijwGei+9vC/zoYitaRNz5AlJ7Mu8c4k JeCz+5tCcl1IL/YX8+Q9jqzfsmXKb8UqeFJmN/gbU0TOIotZMWOa5MixijdCecL7DexgUv0yP 4oBUq9sHhg57gom3604PMVnGp2dN3ld98xHlASKr1YQpO0x76recJZ2ZDEntd0YdDloI9lEul wFfhBDIpRnntG9yQgjQHe1Oge+7GecpSWsoJ9OGsN4BDWSguo59oZx1GcJKDflzM05I3vxMZH QuCgEdBjDa4/jbgyNPxBJ+/vbbUSSOx0h3wMSwApy/xTRPI+cWps4bV/QgQ2JsfWmrAEZA4ee HlrZ1QzKvM5h9XIDO6a7/G3Ze/YwK3CYa2FkWYC0HY2uB+BW4p+e5prjY6Pqlj3/fS From: Markus Elfring Date: Sun, 5 May 2024 10:30:28 +0200 Add a jump target so that the setting of an error code can be better reuse= d at the end of these function implementations. This issue was transformed by using the Coccinelle software. Signed-off-by: Markus Elfring =2D-- drivers/bluetooth/btqca.c | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/drivers/bluetooth/btqca.c b/drivers/bluetooth/btqca.c index cc61014ffbc9..1833aaa6d87b 100644 =2D-- a/drivers/bluetooth/btqca.c +++ b/drivers/bluetooth/btqca.c @@ -108,10 +108,8 @@ static int qca_read_fw_build_info(struct hci_dev *hde= v) return err; } - if (skb->len < sizeof(*edl)) { - err =3D -EILSEQ; - goto out; - } + if (skb->len < sizeof(*edl)) + goto e_ilseq; edl =3D (struct edl_event_hdr *)(skb->data); @@ -123,17 +121,13 @@ static int qca_read_fw_build_info(struct hci_dev *hd= ev) goto out; } - if (skb->len < sizeof(*edl) + 1) { - err =3D -EILSEQ; - goto out; - } + if (skb->len < sizeof(*edl) + 1) + goto e_ilseq; build_lbl_len =3D edl->data[0]; - if (skb->len < sizeof(*edl) + 1 + build_lbl_len) { - err =3D -EILSEQ; - goto out; - } + if (skb->len < sizeof(*edl) + 1 + build_lbl_len) + goto e_ilseq; build_label =3D kstrndup(&edl->data[1], build_lbl_len, GFP_KERNEL); if (!build_label) @@ -145,6 +139,10 @@ static int qca_read_fw_build_info(struct hci_dev *hde= v) out: kfree_skb(skb); return err; + +e_ilseq: + err =3D -EILSEQ; + goto out; } static int qca_send_patch_config_cmd(struct hci_dev *hdev) @@ -224,8 +222,7 @@ static int qca_read_fw_board_id(struct hci_dev *hdev, = u16 *bid) edl =3D skb_pull_data(skb, sizeof(*edl)); if (!edl) { bt_dev_err(hdev, "QCA read board ID with no header"); - err =3D -EILSEQ; - goto out; + goto e_ilseq; } if (edl->cresp !=3D EDL_CMD_REQ_RES_EVT || @@ -235,10 +232,8 @@ static int qca_read_fw_board_id(struct hci_dev *hdev,= u16 *bid) goto out; } - if (skb->len < 3) { - err =3D -EILSEQ; - goto out; - } + if (skb->len < 3) + goto e_ilseq; *bid =3D (edl->data[1] << 8) + edl->data[2]; bt_dev_dbg(hdev, "%s: bid =3D %x", __func__, *bid); @@ -246,6 +241,10 @@ static int qca_read_fw_board_id(struct hci_dev *hdev,= u16 *bid) out: kfree_skb(skb); return err; + +e_ilseq: + err =3D -EILSEQ; + goto out; } int qca_send_pre_shutdown_cmd(struct hci_dev *hdev) =2D- 2.44.0