Received: by 10.213.65.68 with SMTP id h4csp2189140imn; Sun, 8 Apr 2018 22:04:02 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+kg2BewroNgTOnQknF8H8I6IQLxdVl0rw/OlIKLJIfPBzvLssv/ryVzAxqoDVuGaLCAv6n X-Received: by 10.98.87.7 with SMTP id l7mr27923086pfb.148.1523250242231; Sun, 08 Apr 2018 22:04:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523250242; cv=none; d=google.com; s=arc-20160816; b=I0ClTsMheIe1bskESFzeeFp87p97vhmAH+1CtZLIrXWYBjsbum5XBX7dZICjFl22+/ /bvyFhuGKqKlz1nHHG7qaCDn2rSMjdtNNObcbVQQ+raON1HxOABbZ4VX9kasK3o05hCv KPPECRPDUhgwbXbdOnqPij2Uxf0IdmTNFQ+a3QVPdAtQX3y5qy1H8VGIhPG0LRy+4M3C whTXxCisENGkEUXsfEA0zc4y1rRNgTJUBpP0T5yrAxJr1A0SFxSElql5OLjCV9QI7sY2 1mAlhrrFhSKuYiIDyYEaPj2cXi3wKztjEhvHPFIHvgdAyAW/N025DsUVvbeCDPVwwunA mLmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=5YyBx4yDibRSQKLsRstvTyMx+ZQ9um4HKCStREksnhU=; b=XJJa2MgHQD71qcQwxvl6rLJPKh+1OpJ80jbuALsI8Hsi4qCpFzKIQ/P0rG+keStvRW lNXSFY8V4mrRyoA1mRoPnZb9ZjFNjFJJD6lmI3C8fQErPpNi41TKxtkJyX1J3Zmsg7Af 2S6c1qp50bJgMrHoIUoMN4unD/Z/+c36SfLh0+/+VZZgDWlslQIF56rpznMyy8teYkEZ kK4gPMoiLlub3Lx0j4GxsHQI7Nzi2alZvTq37Kt/DNTpxV5tUXTY8LgE4aFhXQE9Oss0 2XCp7nBnZamGi8yHRUStawk90WptIE81fmbRix3Br7iznlqdiGNCH4QAsR+dcgICRO24 Ax/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=nC9/CKfp; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m1si10384985pgu.633.2018.04.08.22.03.23; Sun, 08 Apr 2018 22:04:02 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=nC9/CKfp; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753468AbeDIASN (ORCPT + 99 others); Sun, 8 Apr 2018 20:18:13 -0400 Received: from mail-co1nam03on0107.outbound.protection.outlook.com ([104.47.40.107]:43410 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753331AbeDIASD (ORCPT ); Sun, 8 Apr 2018 20:18:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=5YyBx4yDibRSQKLsRstvTyMx+ZQ9um4HKCStREksnhU=; b=nC9/CKfphg85jqiwB0lsY/GfUSd7EDQTosSGeqtYu1TwlZ+PigHvzsGflbJkvaD9zQ0VEPAbeuGHCrcH09sjVc7k8u6n7Fb2n6hlBEyve5y/GYbfoinxi0b5CJCBnnpbQI3QPYxMxvzDrh06HFMymuF7PAkeuqC4OG2PEcwUyFA= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB1046.namprd21.prod.outlook.com (52.132.128.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.696.0; Mon, 9 Apr 2018 00:17:56 +0000 Received: from DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8109:aef0:a777:7059]) by DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8109:aef0:a777:7059%2]) with mapi id 15.20.0696.003; Mon, 9 Apr 2018 00:17:56 +0000 From: Sasha Levin To: "stable@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: "weiyongjun (A)" , Johannes Berg , Sasha Levin Subject: [PATCH AUTOSEL for 4.15 059/189] mac80211_hwsim: fix possible memory leak in hwsim_new_radio_nl() Thread-Topic: [PATCH AUTOSEL for 4.15 059/189] mac80211_hwsim: fix possible memory leak in hwsim_new_radio_nl() Thread-Index: AQHTz5gm0kxe57aJokKZqOLRcPmeDQ== Date: Mon, 9 Apr 2018 00:17:32 +0000 Message-ID: <20180409001637.162453-59-alexander.levin@microsoft.com> References: <20180409001637.162453-1-alexander.levin@microsoft.com> In-Reply-To: <20180409001637.162453-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DM5PR2101MB1046;7:mDk8rtnC7JdgaNqeemVxiHRvTKMlJmdWr8i0MFAWOglKwqduF4ASxrS+Bg6i7aYdvQiWa9MM49G+gNZ8M7eQnyDaqsjidbaHk+BaNl3NhBznsWhra0bSjNHWTPgC1pxBxdpkELR81FygV1/hRSn3c5Ezk2uDHR3jcg5TCPcT11VLflJ4h85T+nGZx0AssEwu93VZ1ia49pfV1UucGvIaPLnNLrCI0pqsHSwHU/hFUW5Rrj2kr/ug7PwXbfYxnQDL;20:jNqj+7vYY0GgxdGqlCdYsflG7sVREeK2tT8RjeljrOkpLhsW3cq4Bw30xfI6Sd7f7TOtLMGWV9mICIMC61izjpQZ9vA/HegP3wA3GeRztPJaGaVBGiFo0fFiDkyKtsz0Rpiqbpdr05qvaK/baXjRNqGpLXzghd7OOw8ykIMi1hQ= X-MS-Office365-Filtering-Correlation-Id: 57e2f192-add3-4c42-43cd-08d59daf583d x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(4534165)(4627221)(201703031133081)(201702281549075)(5600026)(4604075)(3008032)(48565401081)(2017052603328)(7193020);SRVR:DM5PR2101MB1046; x-ms-traffictypediagnostic: DM5PR2101MB1046: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171)(50582790962513)(228905959029699); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(61425038)(6040522)(2401047)(8121501046)(5005006)(3231221)(944501327)(52105095)(10201501046)(3002001)(93006095)(93001095)(6055026)(61426038)(61427038)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123560045)(20161123562045)(20161123564045)(6072148)(201708071742011);SRVR:DM5PR2101MB1046;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB1046; x-forefront-prvs: 0637FCE711 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(39380400002)(346002)(376002)(396003)(366004)(39860400002)(199004)(189003)(36756003)(575784001)(186003)(11346002)(446003)(476003)(2616005)(7736002)(5660300001)(26005)(10290500003)(478600001)(106356001)(6666003)(68736007)(10090500001)(54906003)(3846002)(59450400001)(22452003)(6116002)(86612001)(110136005)(99286004)(86362001)(72206003)(305945005)(76176011)(102836004)(6506007)(486006)(316002)(3280700002)(3660700001)(81166006)(81156014)(8676002)(2906002)(14454004)(2900100001)(97736004)(6486002)(8936002)(1076002)(6512007)(6436002)(105586002)(25786009)(4326008)(2501003)(5250100002)(53936002)(66066001)(107886003)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB1046;H:DM5PR2101MB1032.namprd21.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: bDqdoDGkgZXEs6P5SX/dfpmzJOqwoH2/4IU08cXKGfoXCGCj9NVa/xqvLMto5zbTUvU8UdQ2ilRpKy0O1EvNuD7GpX51bRnUUFl4Miboh6DltDZEEfeFBQ5U2INJ4p8ajJGJPaugfOjuwbCtufpQwQOfsO9VWH8Ii2exSfLAA3g2tiC96Tf4ygrCi9qnK9KK8MkZmFCbhscK0zAtPzN0LzNNEPoX8Zebolqj2QYBs54Hsru0gPHnRtRPPTSSLPL4S82Z7c/gqnONxM6SdWupYJ9RMTSGTETJfsmqHwTI7d8KDJ/QXZ3wAmS9zKodU+kAnP65fXVRkMZeKvopOBAVrxkzlQaM/mJSHw5y4VS0Mf9H+RM+s6uOmvumVY7RouZtHSuG3+Gl+2a7CBsi6kzsRhrN9aeEsEfImUczRqZmiiU= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 57e2f192-add3-4c42-43cd-08d59daf583d X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2018 00:17:32.0718 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB1046 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: "weiyongjun (A)" [ Upstream commit 0ddcff49b672239dda94d70d0fcf50317a9f4b51 ] 'hwname' is malloced in hwsim_new_radio_nl() and should be freed before leaving from the error handling cases, otherwise it will cause memory leak. Fixes: ff4dd73dd2b4 ("mac80211_hwsim: check HWSIM_ATTR_RADIO_NAME length") Signed-off-by: Wei Yongjun Reviewed-by: Ben Hutchings Signed-off-by: Johannes Berg Signed-off-by: Sasha Levin --- drivers/net/wireless/mac80211_hwsim.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/m= ac80211_hwsim.c index 731d59ee6efe..479250bca605 100644 --- a/drivers/net/wireless/mac80211_hwsim.c +++ b/drivers/net/wireless/mac80211_hwsim.c @@ -3155,8 +3155,10 @@ static int hwsim_new_radio_nl(struct sk_buff *msg, s= truct genl_info *info) if (info->attrs[HWSIM_ATTR_REG_CUSTOM_REG]) { u32 idx =3D nla_get_u32(info->attrs[HWSIM_ATTR_REG_CUSTOM_REG]); =20 - if (idx >=3D ARRAY_SIZE(hwsim_world_regdom_custom)) + if (idx >=3D ARRAY_SIZE(hwsim_world_regdom_custom)) { + kfree(hwname); return -EINVAL; + } param.regd =3D hwsim_world_regdom_custom[idx]; } =20 --=20 2.15.1