From patchwork Fri Feb 18 15:32:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 12751607 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A6BACC433F5 for ; Fri, 18 Feb 2022 15:33:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237051AbiBRPdj (ORCPT ); Fri, 18 Feb 2022 10:33:39 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:51954 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236375AbiBRPdj (ORCPT ); Fri, 18 Feb 2022 10:33:39 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E1C81EEF5; Fri, 18 Feb 2022 07:33:22 -0800 (PST) Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 21IF773A001156; Fri, 18 Feb 2022 15:33:16 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : content-type : mime-version; s=corp-2021-07-09; bh=/DqGKwJwEvEoDhC/wsKYOVzFDlWfRou1p3pQok5jZBQ=; b=qTxeU+B1gA3op7+vWEJvFKlheqRhwfsCw5wMlMukacNx2rQimMsGvOUsSxbtD0btXHc2 +mfg1rSem8Z5Dj/LAnMzsLlOLepnnYjIIUeqIEWPIu9yDhUABDqWyz11vrofYUlDLhsw j1KkKAO94OWbB93h/opiK7ZQSnn/QtLCWUKvcGV8h8VISXuPm14QUKT9EvN1FuNjeRGj P8ZrjW+FUMei2r3/c93PCBdAxw9Sx3J3OWIafdEdDqRd3X2cM8hhlGen310Nt3ct8OK+ TzGogzuNFxMqd0h83AAnPX/E5ZxN6xxK4LHaYDGDneGrkUcP7bxoZ2luFzp2W8fsCPdc Hw== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by mx0b-00069f02.pphosted.com with ESMTP id 3e8n3e1wgb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 18 Feb 2022 15:33:15 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 21IFUeXj081906; Fri, 18 Feb 2022 15:33:14 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2177.outbound.protection.outlook.com [104.47.55.177]) by aserp3030.oracle.com with ESMTP id 3e9bre0uu1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 18 Feb 2022 15:33:14 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hxmx41YW2/Qq1fHK3mNLn+ZCOzm7K5x4k11yckuUTAZ0rWa+GhUka/1T1c/DR5gNkzznjJRg2H7upKO4nq0GLXNfQ1ilvU47mwltQf+iW3AH3TP9jKCwX0wWI8Dc2u/cxuOS1BHmPZn4e82K4iSFLlTpZU4+eL3/AMlqv0AXtJcd9wpq9Mx1Puv+md6+Zsto1lZOirzMau1NWlXRxJ5DR/MUN1XAat70K9FJe4G3WxpUqRjZkWTQMk5Y2gnFV2xJi5FVK+2mAERKnoQqbtJG89Xb+xguyjuazO6CSi/Q4JZJuERaT/TNOtf83yFK2QzHJbsT57IO5YhEiEoutyDiZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=/DqGKwJwEvEoDhC/wsKYOVzFDlWfRou1p3pQok5jZBQ=; b=obxyrWhwHkvFRkwvyAaq3d/EEqs1jsUh8/z0m/yQZrJ086mAFRevoHrl+OZw26BtDr/kMzNQ9ZVekUqpYsa8WhCsShSoiQBWIgCdW+ONtAFXniTOqpRiArl4T/IFH3Dzucz6m65Y1jyNtZ/lRaxQQD/LWSsvsAEYeOA+4274eYRVx4G6AnGtA1Nr6JYAjN/OKsY3msffo9KX3HtutO6PKnV/znDM+IRI45SF4loLuuoAyg5o+WkiX57nLiEnQ9dN+v6jimF35GL0ZSA3xv2I8/JJcPzNaM0sge5uP1QfJblAAjUAY0owLvtIGbaz+lLMPA+QU5twjHt+TRCb8ZExwQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/DqGKwJwEvEoDhC/wsKYOVzFDlWfRou1p3pQok5jZBQ=; b=VT0DkKV/uue4XYrCVxwA8XJ7k956Vh8CijSHVHtBg2iZpu44gSqYgOeWpLexmDelP7M/ZyBIvBGxhK+1BG3oZsOrJ5onkPlyaeG/oMKc2xyNGegEBjuBE65QIVEqlm3u9fGZUEs34yynXFEMw5EwyvFCd3qOAajo1Kv+8eszIKY= Received: from MWHPR1001MB2365.namprd10.prod.outlook.com (2603:10b6:301:2d::28) by BLAPR10MB5028.namprd10.prod.outlook.com (2603:10b6:208:307::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4995.14; Fri, 18 Feb 2022 15:33:12 +0000 Received: from MWHPR1001MB2365.namprd10.prod.outlook.com ([fe80::2c3d:92b5:42b3:c1c5]) by MWHPR1001MB2365.namprd10.prod.outlook.com ([fe80::2c3d:92b5:42b3:c1c5%3]) with mapi id 15.20.4975.019; Fri, 18 Feb 2022 15:33:12 +0000 Date: Fri, 18 Feb 2022 18:32:59 +0300 From: Dan Carpenter To: Karsten Graul , "D. Wythe" Cc: "David S. Miller" , Jakub Kicinski , linux-s390@vger.kernel.org, netdev@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH net-next] net/smc: unlock on error paths in __smc_setsockopt() Message-ID: <20220218153259.GA4392@kili> Content-Disposition: inline X-Mailer: git-send-email haha only kidding User-Agent: Mutt/1.10.1 (2018-07-13) X-ClientProxiedBy: ZR0P278CA0027.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:1c::14) To MWHPR1001MB2365.namprd10.prod.outlook.com (2603:10b6:301:2d::28) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f6bbd25f-71e8-4078-435d-08d9f2f3f8fb X-MS-TrafficTypeDiagnostic: BLAPR10MB5028:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:513; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1usQPYcLE3xDnaYvE5GstxBffKG+Nci+OuAF8Vav8Is2pdY0+WDfZ/ncWI5Asjv31qWNeJzR6dn+6lmLcVCxQd9EzGHDiVCDXBfGaH0t5EMtOCLBdE+Kqx+2k8Na6OcvKFIc6Xoyj0Nd5EvYscNPVhq6lZKIFeGQXcj5Xd1SaKiWgiPT5yrl9RwCFyxJA+hGyFW9pUJbhLFTb7C2GWwJFJmM144nDhNKULiZU1QyP7XIgfwo55OzKlx+yZ5wL24GVkrFUt5pitXDjHc2sCMiIx7lEjfdecdrZeSLfCFiiQwlL2fpCKqMlzozXNrdRxFqVK/D1zTC1HL7VdDm4dH/mjAu1qBidkN4If6tYVYn0OCVmriwgzWpmUTEdytK4qEEX3Mr59Aiva4HWw4F3FhvRrhj4D+GJebjuFnSkvIw+UoP36z9bj3qyV5JTQXLyWbQawP5bkmJJH85kPVO55s8grg8WsWmLG2aPzb94GXSOWWHkloobUtGaINon32mWMpioLTfklmKxHNJoNuguqTDVrhKOuyYTBdHb4bh2O4CaKyyeqz49qgB+l0zH3gff7a+UegK5BC4SR6bDGQF84ffC3ETPG4eAqrv2uQk+qS/9hfhlTzushUSkR9kLPv/hABD913sa8ByGvWimfUpPq4jlA//299gE4Rt5My/ccZwwfExs7Bp+Gu4K0fm4UoWb7lk+rhEDojgwM7NT9Fl0dGij7XU24s7DulD3PhcFbEAsWU= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MWHPR1001MB2365.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(7916004)(366004)(83380400001)(186003)(66476007)(54906003)(33656002)(26005)(52116002)(2906002)(9686003)(38350700002)(1076003)(38100700002)(6506007)(6512007)(6666004)(4744005)(8936002)(44832011)(5660300002)(86362001)(6486002)(508600001)(33716001)(8676002)(316002)(110136005)(4326008)(66556008)(66946007)(309714004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ypyHt/qmrxiSdnqfIt6tG7/XT+XeFnvzqNwMxEDRsX7OvOpwcEIAgs1pnJ1T8obwDYQsWeVzFWnsLqY6wxa/FYZiQqOU2O5J7zBRNrA0pjy0sNtyBoXWmqbyraZhRXemH0Z+KkxKrswhnRypVV8BtQUdQKuwVFltx4CSe0KdeK2L+QrdcUoXF/oSowJO9Bc+rBPaRCI4GSUFwNz6oZHQozyYUhPGaCpHXVdvIfLjzS2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osZUrZmbO46YGjOt13w6psb7Fm7ofKx9lC2cK6SOdhAbBZS2SowOBg6kJNkxgZBhwwt3dR8ChediFdYYaeL44cOXL6apZMFqjIEUgElIjQZ/BRoBsr/APzG4cuKrxymPcB1s4DS+PYrI4cST1DDMFN4FVex/2KC9N5CWUqY1aAhUwYr5vJRT2KwK2HXGFgWWhe0N5d5IozLDp3SlLiuwv8dx6e3GOJK2CIR48Vf9/CJ2RVWel8egu9y0bx8jSmNS+rMV1FGJ6Bar5EqTkeLqSRFk3xdaheQrtbN7jopAkJdghJvJUGQCH02hkjmeaQS9wWcRzC9cASWxL6X+LCHIc43fxVb72WAQA9nj6n/a5UnbnYGEOBciXXw== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: f6bbd25f-71e8-4078-435d-08d9f2f3f8fb X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2365.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Feb 2022 15:33:12.1889 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: YSRxUXAMYcR9q6KnbT225nVbwdXSeNYfryNigqQKoA48qZZFmAEWeTxUuTSL+z8cbQMg4vlcN6IVN72oxOzgYP5MMehpG6f2sJOUf1M5SCI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLAPR10MB5028 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10261 signatures=677564 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 spamscore=0 phishscore=0 suspectscore=0 mlxscore=0 mlxlogscore=999 malwarescore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202180100 X-Proofpoint-ORIG-GUID: cYZIGEXhzF6pl7tBUVgJRgs1ty4ghQTA X-Proofpoint-GUID: cYZIGEXhzF6pl7tBUVgJRgs1ty4ghQTA Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org These two error paths need to release_sock(sk) before returning. Fixes: a6a6fe27bab4 ("net/smc: Dynamic control handshake limitation by socket options") Signed-off-by: Dan Carpenter Reviewed-by: D. Wythe --- net/smc/af_smc.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c index d873afe2d4dc..38faf2b60327 100644 --- a/net/smc/af_smc.c +++ b/net/smc/af_smc.c @@ -2715,10 +2715,14 @@ static int __smc_setsockopt(struct socket *sock, int level, int optname, lock_sock(sk); switch (optname) { case SMC_LIMIT_HS: - if (optlen < sizeof(int)) - return -EINVAL; - if (copy_from_sockptr(&val, optval, sizeof(int))) - return -EFAULT; + if (optlen < sizeof(int)) { + rc = -EINVAL; + break; + } + if (copy_from_sockptr(&val, optval, sizeof(int))) { + rc = -EFAULT; + break; + } smc->limit_smc_hs = !!val; rc = 0;