From patchwork Thu Dec 8 08:26:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gavrilov Ilia X-Patchwork-Id: 31206 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp75825wrr; Thu, 8 Dec 2022 00:40:16 -0800 (PST) X-Google-Smtp-Source: AA0mqf47ceYgeq0kztEosSCMkFgIA4rYOOeErx21XqEEsCR1r9mGz3B+l9qZ9STAACntcYOg7Tq3 X-Received: by 2002:aa7:da10:0:b0:46c:43ff:6961 with SMTP id r16-20020aa7da10000000b0046c43ff6961mr21017204eds.14.1670488815944; Thu, 08 Dec 2022 00:40:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670488815; cv=none; d=google.com; s=arc-20160816; b=GiuL4NGv/BkHMLWdWIJPSSf9FopR1oBkJSHUsBt0BGcBDcAzwRTMkXkzJ5jIOHW1Wc nzI8rpwDEwgFlJrc2U62Rr81SX5aWWg7b8R4dGR9i1xx+p5JWFBx9VEWfoA2ZresSlKA FpPAH0VK7xPc9v/qJQxUm6x7e4S5qD0H1f7N5+qleOYLUHkZ8wxdraobmT3cIJFWU5g1 nV0lxdxrByiv5Eg9ktIn/VkXJWW08RrTYiscdpWH0A0lKNLX+dHXC7IrdSrrK7OdjO/T fZXdbijhUtFySFJDZaYrmySX7Rbv0RJUVHJHRZea99MB5ubsWV1Mp8kSytGdyvBXZeq0 9kVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :content-language:accept-language:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature:dkim-filter; bh=s0kXhZ5QwF8NQVrywWavoH3BbIaBSkcol4p+WMzzHbA=; b=oCazLBKOIQY3KmldKlzlBVpLVBCcoTls7TkNH2Ry1KVQuX/V9+GA0FFDeqhNdA2f25 rL3IZTD5PUbhFFYkp73IsXulVTvTsOWOYqA3PzPM10fS7En0OmbRHgmlKMdX7flhtaXS FW0uJrYZE2vvnbXXhJLNYciaWAaVq4sMWrA9byY/DszW8UL2m19oqnzm1s7DB3KdXLyH +RLoxDqg3fMIjGihFW7id0MDhcHKkbRXcC3MKak594zN2KIsbM1POkF+ULrqD7mGaXBW Vv9vclTTrhH77By0IU18gAH4NOnSGM7z1lBMUnaYVR+JMyFNd+cW5Ima+IIxW+Yn1OEK RzDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infotecs.ru header.s=mx header.b="Odhxsp/y"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=infotecs.ru Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id du16-20020a17090772d000b0073de493b83esi7698135ejc.147.2022.12.08.00.39.50; Thu, 08 Dec 2022 00:40:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@infotecs.ru header.s=mx header.b="Odhxsp/y"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=infotecs.ru Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229781AbiLHIe6 (ORCPT + 99 others); Thu, 8 Dec 2022 03:34:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40590 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229462AbiLHIe5 (ORCPT ); Thu, 8 Dec 2022 03:34:57 -0500 Received: from mx0.infotecs.ru (mx0.infotecs.ru [91.244.183.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C4AD65E9E1; Thu, 8 Dec 2022 00:34:55 -0800 (PST) Received: from mx0.infotecs-nt (localhost [127.0.0.1]) by mx0.infotecs.ru (Postfix) with ESMTP id CC69B1182B4F; Thu, 8 Dec 2022 11:26:57 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 mx0.infotecs.ru CC69B1182B4F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=infotecs.ru; s=mx; t=1670488018; bh=s0kXhZ5QwF8NQVrywWavoH3BbIaBSkcol4p+WMzzHbA=; h=From:To:CC:Subject:Date:From; b=Odhxsp/yQQ9jHQH54WIsk46NzZXhtblFcJ6Ujtjvtjb8aYD/EZeLdV4DSDye3AlUL VKlJ8qHPtW3mIhPrlyx8l9ugaezJiHpXk4kobWaxPgvg7AOtQcpWqvxtEb8YFXq/Oj bcMsHGqEzgu2kKYvTTHTc/kECV9TU6q20ZrDAIdk= Received: from msk-exch-01.infotecs-nt (msk-exch-01.infotecs-nt [10.0.7.191]) by mx0.infotecs-nt (Postfix) with ESMTP id C9A80301A0D5; Thu, 8 Dec 2022 11:26:57 +0300 (MSK) Received: from msk-exch-01.infotecs-nt (10.0.7.191) by msk-exch-01.infotecs-nt (10.0.7.191) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.12; Thu, 8 Dec 2022 11:26:57 +0300 Received: from msk-exch-01.infotecs-nt ([fe80::89df:c35f:46be:fd07]) by msk-exch-01.infotecs-nt ([fe80::89df:c35f:46be:fd07%14]) with mapi id 15.02.1118.012; Thu, 8 Dec 2022 11:26:57 +0300 From: Gavrilov Ilia To: Jiri Pirko CC: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Arkadi Sharshevsky , "netdev@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: [PATCH] net: devlink: Add missing error check to devlink_resource_put() Thread-Topic: [PATCH] net: devlink: Add missing error check to devlink_resource_put() Thread-Index: AQHZCt7VLcCQYXqvEkyWdGuOlfYO7w== Date: Thu, 8 Dec 2022 08:26:57 +0000 Message-ID: <20221208082338.3923376-1-Ilia.Gavrilov@infotecs.ru> Accept-Language: ru-RU, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.17.0.10] x-exclaimer-md-config: 208ac3cd-1ed4-4982-a353-bdefac89ac0a MIME-Version: 1.0 X-KLMS-Rule-ID: 1 X-KLMS-Message-Action: clean X-KLMS-AntiSpam-Lua-Profiles: 174026 [Dec 08 2022] X-KLMS-AntiSpam-Version: 5.9.59.0 X-KLMS-AntiSpam-Envelope-From: Ilia.Gavrilov@infotecs.ru X-KLMS-AntiSpam-Rate: 0 X-KLMS-AntiSpam-Status: not_detected X-KLMS-AntiSpam-Method: none X-KLMS-AntiSpam-Auth: dkim=none X-KLMS-AntiSpam-Info: LuaCore: 502 502 69dee8ef46717dd3cb3eeb129cb7cc8dab9e30f6, {Tracking_from_domain_doesnt_match_to}, infotecs.ru:7.1.1;d41d8cd98f00b204e9800998ecf8427e.com:7.1.1;127.0.0.199:7.1.2 X-MS-Exchange-Organization-SCL: -1 X-KLMS-AntiSpam-Interceptor-Info: scan successful X-KLMS-AntiPhishing: Clean, bases: 2022/12/08 05:05:00 X-KLMS-AntiVirus: Kaspersky Security for Linux Mail Server, version 8.0.3.30, bases: 2022/12/08 05:14:00 #20660675 X-KLMS-AntiVirus-Status: Clean, skipped X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751634480438459197?= X-GMAIL-MSGID: =?utf-8?q?1751634480438459197?= When the resource size changes, the return value of the 'nla_put_u64_64bit' function is not checked. That has been fixed to avoid rechecking at the next step. Found by InfoTeCS on behalf of Linux Verification Center (linuxtesting.org) with SVACE. Fixes: d9f9b9a4d05f ("devlink: Add support for resource abstraction") Signed-off-by: Ilia.Gavrilov --- net/core/devlink.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/net/core/devlink.c b/net/core/devlink.c index 89baa7c0938b..ff078bcef9ba 100644 --- a/net/core/devlink.c +++ b/net/core/devlink.c @@ -4193,9 +4193,10 @@ static int devlink_resource_put(struct devlink *devlink, struct sk_buff *skb, nla_put_u64_64bit(skb, DEVLINK_ATTR_RESOURCE_ID, resource->id, DEVLINK_ATTR_PAD)) goto nla_put_failure; - if (resource->size != resource->size_new) - nla_put_u64_64bit(skb, DEVLINK_ATTR_RESOURCE_SIZE_NEW, - resource->size_new, DEVLINK_ATTR_PAD); + if (resource->size != resource->size_new && + nla_put_u64_64bit(skb, DEVLINK_ATTR_RESOURCE_SIZE_NEW, + resource->size_new, DEVLINK_ATTR_PAD)) + goto nla_put_failure; if (devlink_resource_occ_put(resource, skb)) goto nla_put_failure; if (devlink_resource_size_params_put(resource, skb))