Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751270AbdFDNIM (ORCPT ); Sun, 4 Jun 2017 09:08:12 -0400 Received: from mail-db5eur01on0059.outbound.protection.outlook.com ([104.47.2.59]:20540 "EHLO EUR01-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751182AbdFDNIH (ORCPT ); Sun, 4 Jun 2017 09:08:07 -0400 Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=mellanox.com; Subject: Re: [PATCH] devlink: fix potential memort leak To: Haishuang Yan , "David S. Miller" , Jiri Pirko References: <1496580592-13659-1-git-send-email-yanhaishuang@cmss.chinamobile.com> Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org From: Arkadi Sharshevsky Message-ID: <1c80b8da-3f00-48de-f89b-75cf18eebf5d@mellanox.com> Date: Sun, 4 Jun 2017 16:07:43 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <1496580592-13659-1-git-send-email-yanhaishuang@cmss.chinamobile.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Originating-IP: [193.47.165.251] X-ClientProxiedBy: HK2PR02CA0079.apcprd02.prod.outlook.com (2a01:111:e400:79ab::47) To DB6PR0501MB2455.eurprd05.prod.outlook.com (2603:10a6:4:5d::8) X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB6PR0501MB2455: X-MS-Office365-Filtering-Correlation-Id: 38d5d606-c35f-41b6-bb18-08d4ab4abc6f X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(48565401081)(201703131423075)(201703031133081);SRVR:DB6PR0501MB2455; X-Microsoft-Exchange-Diagnostics: 1;DB6PR0501MB2455;3:oMYULQzrkbxUDiGvsI4Za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ZFg06FloQ2frR9H+QDQSQp0wU=;20:/qox5e9MUklyQx+CzofCttYZuL7jTA2XsB2wd4NxB2PPszh4GQUgZbIvGQefBeAu7kw+gI5W1rfd/QB4bPFXjB0tip47tyiW3Y3R2MguFY5jJm/UUH9JUFBuHBDryXMRoOmdyWOj3zsLPI6bKcLzzRy+8acakG1u4C8wsXhzFEO09Ya+Mzz28SwsQauocHcZKnm5EEjqf0iXJy9JZpsqQmUKXzCbUCwEMh5Sq69KIkeZmOPNt1nkfeezfVvaa1YQ4zHx9rDS2POv4zKtFNQthygATBmd8RDCTtKz7OcyD2kd67BMuwyUDIfTrmFmuC9oGWn6igXkvGb1EY138NbhZj7OgEnhF1iCalyiTR2zS8bAsgxllsOqzj9mIlwaAmlYxb1LJkRXRwLK8eZx6mipUHYQZ7t0zvWVOGQiI5lifFr/JIawouzhqUTJJYUC2a9AfwM6urUJt2SHIlk7s7LSSepwQ1wdjhrUKF9vMQ+5uLKAyWLKuQ9xQuqyIoGnNM0h X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(8121501046)(5005006)(3002001)(93006095)(93001095)(10201501046)(100000703101)(100105400095)(6055026)(6041248)(20161123562025)(20161123555025)(20161123560025)(20161123564025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123558100)(6072148)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:DB6PR0501MB2455;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:DB6PR0501MB2455; X-Microsoft-Exchange-Diagnostics: =?Windows-1252?Q?1;DB6PR0501MB2455;4:h2LpzJCdIkX94E8vbxq188aPnNCPH7cGbJdO?= =?Windows-1252?Q?i0SvhpAj3y75Glmf7GxP2JqQMjc6mBwTcsDq2WJ8rR9SCfKJoadlNPg9?= =?Windows-1252?Q?49S/yLz+3H5N690mpwzQRf41JtPzFIhnI+WrtA/udXmHPVEHkbIdfFiC?= =?Windows-1252?Q?E5am+2psGV+yaeTCJZqkfpUcrK7PERJbiGL49QlZKTpvr1Yf+fpwltH1?= =?Windows-1252?Q?8aGx5dY7eF4y/kdREkZhFhcmG+o1CdahoK3jkFSOsfdX8bp2ZqMJaFqo?= =?Windows-1252?Q?6R/580A0LbXPhyoiO1FeIu1WRmf8YhfOjrQW4km8VTFgdm4C0E0BLtB0?= =?Windows-1252?Q?90SXmv9TLvKQzw2fGtntNLpT7QhkMV5OCtmrYzhiELjH5SjcgEM+PMMS?= =?Windows-1252?Q?pCDGBKS3Sk5o7eCHv8K6r7J7NxcqCPMyP9GFCYvzMIbRfuB11Fcez9uK?= =?Windows-1252?Q?CGwd6kAKKqgdRZylD/2bXwPxQbEgqoqZAI3YhJLvIB5T8q4KlTqgGJik?= =?Windows-1252?Q?X9CLwx3wcMogKztdBfZvb5F/fmNDaMr6wbk+U4HX/aewMedxF10CZzYP?= =?Windows-1252?Q?U9kQiBKGK42TbrlJHHUZw4aH1eA3Y4v0yN4SVlQF6gV6w47wdkPT2YpE?= =?Windows-1252?Q?CHDYFidmiRv0gndDh9wBs6oYp31c2MIOPVv2fhnPOhc4Uef3YX2xAssR?= =?Windows-1252?Q?57xwN4Yyht2+xZFTlWxJHA1sSfOA12UrTgb7Ry8Yj5c5zdr04TIsquDQ?= =?Windows-1252?Q?nJ1QTLuEIsIr9Y8Y13PKPmV72BiegyMZAmrVGgz0p4vR5HFGKarhkKyS?= =?Windows-1252?Q?ghdkmcT+OcYtxbXlOWGL+jEtkapMkpaLwLg603Ek38KFma38ObkaBNyj?= =?Windows-1252?Q?epyaSdD6Axy0rGag22OqmWKbFZaI5nhb2F0XU9IXaV19mHOePNlNl5Q4?= =?Windows-1252?Q?2Ya8eHFJlmQ8DboKRepMcHvwHnwFJdiyPcMvzjLS3ltcnRPYjFFGJ3de?= =?Windows-1252?Q?zyOlPPd1pUk1mhmlRsbhciotXTMsPC3uWmGfURqNhUIAqeiM7JpqiEsB?= =?Windows-1252?Q?4yRnyma8p9X0tMWDzcT8P14+kjHiA1RoyNxIAgQfY5dvr7/TrWXUZIIA?= =?Windows-1252?Q?7N1UbB6sTxC/MQqaTAY/fM86r/+IBy132HN8MmoXGOFUHX33aszdY2+U?= =?Windows-1252?Q?Sp6d4YNUQKggrRN5Bc2xnM8bU6uFLaQIsiV5Qvz1/7xGWrGyw7t6Bgzy?= =?Windows-1252?Q?og0gN5yOFjoDdFUJJQ=3D=3D?= X-Forefront-PRVS: 03283976A6 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4630300001)(6069001)(6009001)(39410400002)(39850400002)(39400400002)(39860400002)(39450400003)(39840400002)(24454002)(377454003)(3846002)(6116002)(189998001)(50986999)(76176999)(53936002)(86362001)(575784001)(33646002)(31696002)(6512007)(6486002)(230700001)(6506006)(38730400002)(50466002)(65806001)(66066001)(65956001)(47776003)(31686004)(42186005)(54356999)(4001350100001)(6666003)(6636002)(2950100002)(229853002)(8676002)(23746002)(81166006)(36756003)(2906002)(478600001)(4326008)(53546009)(7736002)(5660300001)(83506001)(305945005)(25786009);DIR:OUT;SFP:1101;SCL:1;SRVR:DB6PR0501MB2455;H:localhost.localdomain;FPR:;SPF:None;MLV:sfv;LANG:en; X-Microsoft-Exchange-Diagnostics: =?Windows-1252?Q?1;DB6PR0501MB2455;23:IcXyYCurjrrDIIwd4p6no2jC5Li/2tbvUYg?= =?Windows-1252?Q?vHQdGkoINtGDaak7B9WulNJvWpYeywO/97V35MPtIIB+ZzL7nZ66enUm?= =?Windows-1252?Q?UqNpJ7DlZH5Dqz0v3MEZbYOsaxfZ9E7Zl2hfk5f1hE5PJlVYIdyMU1C9?= =?Windows-1252?Q?84HuncN/Ht8OVhMrWtzoYIiQHgjS/RFc0gOkAAqzVXL9ID3VvNZs9CYQ?= =?Windows-1252?Q?8uxxVVyrcc/BaNWMPbIXhGkj+tSz46HxSmiLIu/RPwFp9QDgQD4Zt/3+?= =?Windows-1252?Q?MhYsqRQicjOX3LR5LJjkcvldiFZGrKdEEKIQVUhbHo17TV1VksZ9JmCE?= =?Windows-1252?Q?6Wx8+XEsP+N8gHWRyKTeVVri1oI92bBcRItrNl+Sp6XmuPBN/Ydemx3a?= =?Windows-1252?Q?FsOFrvMsnSzLa6YEUwrE+EnBTGNyEhKQb54JWVk2EeC1B02HcgQ78t2b?= =?Windows-1252?Q?OA55LtQni1qhIjwuR+hKyyWs+FJEGpV9CsCGjf+KxwMiAdmUlZ4OwLAp?= =?Windows-1252?Q?vaPn8LBdjd6b4LNp99cfHM7SFywYkEqgPDEmvKw3EpUeqrA2Ifx6Gk9k?= =?Windows-1252?Q?bUOpvx+a7ptzSOm1fELozD1xo7LbnYL/YeLOcP4mbEWndNtDRDe8mUml?= =?Windows-1252?Q?bv3QvgpBjg/U7jesd4wbzMBoifCDEIuKtWanWzleFNDrUrGG2Z2LgAaq?= =?Windows-1252?Q?MAjfsTym/UvVsPP3YjGJkbUCEtpPyX9I9hbwzQHfEjLtKYvCq0MhwUhv?= =?Windows-1252?Q?/GTWH53r2uS9tV2HSz2hjm328dIzCgSONvNfDybNmv3dTdgk+ZzKlTH6?= =?Windows-1252?Q?zN+vSvApA8CZZusDAkYXnOIA5kc8UkhS9uE+6GlvS7xg/3xaS0AdBY+o?= =?Windows-1252?Q?srM++Piu5qzXPs0Ph7I8BUeNKse9rDO7FxxQsPzIl0yo/ZJDZvDTY9LI?= =?Windows-1252?Q?lCXOxIMxFqfwS0UT9nUNCkwuXW3HusA69jkjZtxuDrETOws1rZAyUVei?= =?Windows-1252?Q?txEwQiGyP00e7ULdbMLp3WicEFnj7YtkvpxmOZDOWluRvoh2sOmFQ9Ej?= =?Windows-1252?Q?HO8VCtRkdEsa5nC7ApJsCqRbrHQD1vh4VljBVGR4wHWQB/jOBIS/W6hu?= =?Windows-1252?Q?RO00fs/Q0Fj9wY4BTMZo/rZSHY3sTt3lb296Loy9JjC9xXbXtnJdNlUI?= =?Windows-1252?Q?kJMbyem3i14lv8w076eHkWTlCotm3M0Zv+uqsD/6g4zSwAhQRiE0asSD?= =?Windows-1252?Q?AFB2ki1phPRX3d1s05AEzEtymZKAkKC+ntdbFDQZwJeneU8nMyZ68h6t?= =?Windows-1252?Q?i1K0dTZrYrtBSVAkYm7qPp+bZCTpAfuXN9WZOmQYdwcIUEOl68SvI3Kz?= =?Windows-1252?Q?CjWjaOsrKsxEVju/2eTIlkuroaiwbgNqJdw=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1;DB6PR0501MB2455;6:B7Qb30d6PWkV3LH3E0S15RZL+Ro2ZgCz6LFmjuLZOn4BMlu1ev2PeN3wbBF2HgdwsHDkLVyYGWuGv+UVIZo1K3eNEqP1ayxFUFZv+QTrPKC/KnfGzix2m6D28aLpAUyhMl2mIECzxqQlws7Ywrb6FAz/OPd9NFQsKWChcvItm4sfpQZlmSBcHPXyiPgTGCuG+qieNk8YiQsYtCEebW7uf8ZQrRDfwKdO6N9eInxp7BonYI5KNYYdZCWdr6VWyR0DGAHYMkYiPN7Da+9f3cs5rIihgIbdmPFFZyH1L53vryyAf44jFXrP85a4FWnjDbK25pn4k+NwSnbHpe0WELf/7P+Aa5jA04pYjw6HIgC/GE6xV0Y7pi4uOk/cKVE5JJg9TwbosEKCXZKW3nlJE463M0VJVgXomCDmSsrtMfaccv4/9CNPd+mj8csInvLxoQMwEjTqHEKCjHyMwtjHPeQjm3FukdLOxrCGmz5JMOYxVoR1vGTt45U+cNynv7HYjMPBIMBQW14TRHZmeXqdl+3/KmZxoyWsaGEZqmaUx2ZZ8Ro= X-Microsoft-Exchange-Diagnostics: 1;DB6PR0501MB2455;5:34duoED2czVCo5rT+9W9D8GEzecfEJZQxOb/Qxe0Mig67WP46hiH/nlakqj7YKwXtEEVoP5fAZYgN36sSiQ3o0mJ9VnxWNiBypOFqzOPqweEOn3i5JhGBfh5XrNrJdAkW7gSRxPxyIlgZnFF1FuKFYd2oXU6nP1P3rD5uvsQUWSLHFUAu3VRFW9Od687/pODPMEUHArHOKR2EWtPi3iOpOH/pHVzwOdXJ7badS7t58kF5un2pXGWC/cPOBNR845ozEkH3iCLxLJhmw1i2TJQ4CFMNw7L9QxBPKACECnSnkp3H6iTMadJPgw02pNVtrmHcUOp67rlkDZVD7GQ/kpis8t8Qk0T5gm4j/IoyNQDPxd/tn/xT+DYzq/BaviTRzj/6tQQW0oCbnKwCjK8e2qPgGxeR/kNYQaET105RtHbWLSUeWV/Yn3vW81EaSekaDGQmYEFVbgRdTpw+q1Y9UaWyKXoi7FJsDHDjHY8zyDqLawhL0NVRo8pm8E+xhrpzabi;24:iTzSAxpkrBQiv3ZSxf02vOW1VcFERwCiJDDXxMAgFWemNa9+J9EAxbH0Q+AMX4Zhey9Fhxr0zpuaWSsehFG+Q0+H7lZs1EEKMX2LgFN9q7s= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;DB6PR0501MB2455;7:0s8BdrVbzwbswJAbCtQ8yPfZ2wq1Shr0g11AOfBceaeQF4J/vgkMtuGOci/4dSXbrXEMfzJ0LWuP87qX1Q2lAqVkeT5623oZrIB3xio3o36JOeHcOqJ0dszso4bKgSRvmSJDgmnicm7+t7ZsFOJ+Uy/i6zYwSjwKe5Spy3TvMImW7f8XBZmN2tAS8xo7EV2pstWz84NhpBBVRRapSJbstIjwgMNuK2oix8SXKYIHxCn79GIErSXsw//nlsHT9wBO8WppnyI6mbktM1qCWQkqIB83aH0UTwGcjOCt+WO/Ad9IScnd+TOyWjZBgThFqMhZcldH8NVmjRDBFPCMvuKCJw== X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Jun 2017 13:08:00.8294 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0501MB2455 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 987 Lines: 32 On 06/04/2017 03:49 PM, Haishuang Yan wrote: > We must free allocated skb when genlmsg_put() return fails. > > Fixes: 1555d204e743 ("devlink: Support for pipeline debug (dpipe)") > Signed-off-by: Haishuang Yan > --- > net/core/devlink.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/net/core/devlink.c b/net/core/devlink.c > index b0b87a2..70b69c6 100644 > --- a/net/core/devlink.c > +++ b/net/core/devlink.c > @@ -1680,8 +1680,10 @@ static int devlink_dpipe_tables_fill(struct genl_info *info, > > hdr = genlmsg_put(skb, info->snd_portid, info->snd_seq, > &devlink_nl_family, NLM_F_MULTI, cmd); > - if (!hdr) > + if (!hdr) { > + nlmsg_free(skb); > return -EMSGSIZE; > + } > > if (devlink_nl_put_handle(skb, devlink)) > goto nla_put_failure; > Thanks! I think it a bit better to set the err and goto down the error path below (only nlmsg_free()). Headrs_fill() also suffers from this problem.