From patchwork Fri Aug 26 15:03:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 12956160 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 67624ECAAA3 for ; Fri, 26 Aug 2022 15:04:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234995AbiHZPD6 (ORCPT ); Fri, 26 Aug 2022 11:03:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55358 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231171AbiHZPD4 (ORCPT ); Fri, 26 Aug 2022 11:03:56 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1EF1BD9E93; Fri, 26 Aug 2022 08:03:56 -0700 (PDT) Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 27QDccBl006811; Fri, 26 Aug 2022 15:03:44 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-2022-7-12; bh=lQDGpIsIqEf1gxRXqFxM7t+a5T863++LojWinDC8JB8=; b=Q8/R358v5oA7VV4vKxEVATGqoZzXXVWgwj+kC/GLm9ZVrY59+m6MW1pLDJ79PFqGPZ6B 9qkmMmkFscw/m2gXDQdnIkkDyl1sucTxMazc/JZn3MS96kxjtjhsbaBrrJhRKj/5+wHy WuawStKeW54SG/tuKLxXTLQpzF8rI8ZTpkc4TLLcBMVbqVQZQh/CcWQmwt5inq5OXNdv cg8GR5syMstHq+fmYpC5uzv+RXcR1bIv9OUCvKn1slM23ueQp2WenNle47EsQzLZGC5q t8Hn/McWfciqXTB3JS/SX7N1EjpIefwnMZZNLnTuTgzJn2gqt78My5E8AqmAXWN6aQVO Eg== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3j4w241w3q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 26 Aug 2022 15:03:44 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 27QDqItZ028265; Fri, 26 Aug 2022 15:03:43 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2103.outbound.protection.outlook.com [104.47.58.103]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3j5n4nx8cj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 26 Aug 2022 15:03:43 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Rc8btwjLH/yFOAEHnE9zaKiYHVduTjaU/l0t3dNWh9+G84m4MvV9ShFR4fNuZDYQdginChVGlGZJiSu5hf2O9LZH1u8sZ5zcxJPw77ugllskyMWnzp+VDxhlL1jB/SBXrlOsWihhmSGw8aYzLYw1zWDzsGJn5cPlJ9lueQ3iluX5jjs+LAuLjJR5vvS3IvDtgVGUwM4V2m+s/YjVo4NnhA4E1dPiEqq5cEiSxPGnoUj6f8/NxMgHiMVHbPPAPvDoxmkGLMQspCL7fdzSBiv8npdUB6jmRxrzTmpxSvghNtr59YmBrzqYLSnSmjJY7AP0QaN+4Mpn0FkZAaIf6mzZTQ== 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=lQDGpIsIqEf1gxRXqFxM7t+a5T863++LojWinDC8JB8=; b=PXV7nygksu7fAbjYaXbDyTORSK0zdbhJsTAmtYBeS6LA1+mDEKF/cy36TJ7tCVKnDQy+d3KedUx4d/OkryM/oQYaFZWYnQPf61rraHF91zdNOz2jKkMMoaSUvFpTU4T0T4E23sgGcKpnrB24Oh+/lpOUJBnF/aIBS8Xzi29biaJaosFV1rzQ3LC3dmpC2j+Dvi9WyW9BDnXCjUNpW7oe3W5b+3YGQu63I5xDH+fky9b3aY+5KqbtwNqHQezyJ5K/v8uPF48AW0QqaBI7u0xuUzqea/M6PjGrw+DG9HNJSfU9BemLWXz8moWs+f2V3WBCLP3rqZn5sN5UXkVmO1wi/g== 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=lQDGpIsIqEf1gxRXqFxM7t+a5T863++LojWinDC8JB8=; b=eP+ApUuZGYGk4QhwsW3WnyAdMe1UVUMIq6myIN32/l3tF/CekkKZp3wlRzRjyJDjSHbIRuIRym+u+W7fDjx8RS5tlWzFDmZOeNedFDERwdkhjur1ezs7wJOMTH937Qx20vQKkNpWxUQ0ZCarfTvzH1O3ZKKmrxVj1hIP/Vrbfe4= Received: from MWHPR1001MB2365.namprd10.prod.outlook.com (2603:10b6:301:2d::28) by MWHPR10MB1389.namprd10.prod.outlook.com (2603:10b6:300:21::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5566.15; Fri, 26 Aug 2022 15:03:41 +0000 Received: from MWHPR1001MB2365.namprd10.prod.outlook.com ([fe80::209e:de4d:68ea:c026]) by MWHPR1001MB2365.namprd10.prod.outlook.com ([fe80::209e:de4d:68ea:c026%3]) with mapi id 15.20.5566.016; Fri, 26 Aug 2022 15:03:41 +0000 Date: Fri, 26 Aug 2022 18:03:30 +0300 From: Dan Carpenter To: Ido Schimmel , Vadim Pasternak Cc: Petr Machata , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jiri Pirko , netdev@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH net-next] mlxsw: minimal: Return -ENOMEM on allocation failure Message-ID: Content-Disposition: inline X-Mailer: git-send-email haha only kidding X-ClientProxiedBy: ZR0P278CA0071.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:21::22) 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: e7d4683b-6202-4a3c-9699-08da877429b4 X-MS-TrafficTypeDiagnostic: MWHPR10MB1389:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: sfOcO77H3rZ2Pg6X6V0aF0FbrW+IsTK1HspWHJIgllhDBwGoJ4RBZAG59NRrfmmCddbLCO9DYmOta524ONdtRvcSbFZF+bTJK3PhGu/FkEwe2OffUd+8EgfyiFXsmwAzY4LLs6HWsyEaVFChjkccaW2knCHfZnH+uL1ZWRDfnUjGLyNKRrz22e9zOGJfEFA0XkL+5JE1Z3EfXwtCyyUQA56hj6mj5JFPLV+wpdtM3z/xu6A14IuGMgaPoBf6DmJRcYghQFJr0L9YYbeRMDMTih2rlWbeiTPNTvZ7xdVpYVGHxU8h+qptxK7GJ5irRCYJ9NBpCAAUpNCY1tGro+D8qELlKNs3MCK6/jBupa6oTeqTG2YuLY4SyebHjhP7Xd22n8ZMJR76CuqGb7pGcGtdApuzJEKfxIQyDU0qc+D7BtHtZyl1oLstJ7nVDlF+DmhEtFzEMAx8U4EwRSzuSrjA9TLoMQpIYaLoEEC9edSq/o3g7lT6d6BkMwlPBoUVy4XU7aSv1Do0w8X1n86N0Hco/NCWWz0psX4vpWkksmA6tMYBAgaRFkjj3GQVYl2ONzYkisTluUXe8rwiFbkwZQ/OUKVqsYOxui3afpit2tFKmh9Me4c3yVtUrYESq/8oaVWDW6OQcg7j/NaZpjdiOqsD4Cg1OyAEGoNuLQx3TzpunKWrp2lpIg4rhaHtF36joHQNBWooNcAglF3IQbu43f8e7kKLMh/OuQUWEjRoGPOyOamRSOO43R1dbzbNm0YDTW4oQ2dIEu/Ris+WeSlH+S0G2Q== 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:(13230016)(7916004)(376002)(346002)(39860400002)(136003)(396003)(366004)(9686003)(26005)(2906002)(6512007)(110136005)(6666004)(6486002)(316002)(54906003)(478600001)(52116002)(6506007)(41300700001)(86362001)(8676002)(83380400001)(4326008)(66946007)(33716001)(66476007)(66556008)(8936002)(5660300002)(7416002)(38350700002)(38100700002)(186003)(44832011);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: FSbO9gkE7LA/cNWMRhjmKh8qlQBneSH/tRwx2o2FoHPW/C9AcFjBcaPv5C+4USuQCRB3W3e1537RWEpfx1Q19Wca5ZJI0rKAfcWxge0Onl4dvj7F1emDrNwFC8g443XtxbVcdjmY9W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boorHP6SY6ji3I83GNEq7+V+gsU0WhWXFF5qonmn1wuGl3+CU1p8jtYBvHHD4qLzn6X5FEVH4O4nWc16r1FZ2DY91h/uRJcQGuht8TZMUehizPyaDLZ6c76PDfRCWoVV6RTL+fjJ0PXxb5Qh4rritr+XgvuEBKmdJvC+bU76HsvGoh1nixnJZc0FDA7QVf2fcXlbIBY/uxMw8UcOcO4QpBc2uPoUNQQ0inKL/DLn+hBNlA+scRPjb2KRvsMTAgDg/9P1rIGRDaFk27HGltzznOog59YK4g7xZ6RH8zou/ge1Hqbp07J4lAStA4xzh+NdTnQTFyjckZnbUQHPZ0W1911w6Ii1Y2CdcANIWtShKX4TTI+UI2DOj5PiiIcE72qd781r11okqvrfKnfsuycwYqFZjw== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: e7d4683b-6202-4a3c-9699-08da877429b4 X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2365.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Aug 2022 15:03:41.4815 (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: MTX7U9FO+O4Ay95w0Ph8nZVLnxVlD4cIjg17/dnxdaF7HNcIkXtPdHtrPzZWLy2azTnIsH1gAl+fUHBEHpoZdgyV6YDFGhKFlz49kZDxsC0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR10MB1389 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-08-26_08,2022-08-25_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 mlxscore=0 phishscore=0 spamscore=0 malwarescore=0 mlxlogscore=999 suspectscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2207270000 definitions=main-2208260062 X-Proofpoint-ORIG-GUID: g-fcJm4ZqbsSVBY5AaxDCMesQTT4N8Es X-Proofpoint-GUID: g-fcJm4ZqbsSVBY5AaxDCMesQTT4N8Es Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org These error paths return success but they should return -ENOMEM. Fixes: 01328e23a476 ("mlxsw: minimal: Extend module to port mapping with slot index") Signed-off-by: Dan Carpenter Reviewed-by: Petr Machata Reviewed-by: Ido Schimmel --- drivers/net/ethernet/mellanox/mlxsw/minimal.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/minimal.c b/drivers/net/ethernet/mellanox/mlxsw/minimal.c index 7d3fa2883e8b..c7f7e49251f4 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/minimal.c +++ b/drivers/net/ethernet/mellanox/mlxsw/minimal.c @@ -404,8 +404,10 @@ static int mlxsw_m_linecards_init(struct mlxsw_m *mlxsw_m) mlxsw_m->line_cards = kcalloc(mlxsw_m->num_of_slots, sizeof(*mlxsw_m->line_cards), GFP_KERNEL); - if (!mlxsw_m->line_cards) + if (!mlxsw_m->line_cards) { + err = -ENOMEM; goto err_kcalloc; + } for (i = 0; i < mlxsw_m->num_of_slots; i++) { mlxsw_m->line_cards[i] = @@ -413,8 +415,10 @@ static int mlxsw_m_linecards_init(struct mlxsw_m *mlxsw_m) module_to_port, mlxsw_m->max_modules_per_slot), GFP_KERNEL); - if (!mlxsw_m->line_cards[i]) + if (!mlxsw_m->line_cards[i]) { + err = -ENOMEM; goto err_kmalloc_array; + } /* Invalidate the entries of module to local port mapping array. */ for (j = 0; j < mlxsw_m->max_modules_per_slot; j++)