Received: by 10.213.65.68 with SMTP id h4csp2117283imn; Sun, 8 Apr 2018 20:08:17 -0700 (PDT) X-Google-Smtp-Source: AIpwx49STXG8GPX8RG0Tre7CCzC9zyp0hJfw/tiwtexogHgKhjlVuGWyiCQqWX5a1d8JPYM3at3v X-Received: by 10.98.214.91 with SMTP id r88mr27711647pfg.8.1523243297600; Sun, 08 Apr 2018 20:08:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523243297; cv=none; d=google.com; s=arc-20160816; b=TwAUY/vJYwovfF5VUNPZsr9INl14HMw39OcB8hsuQUNSXCq2uyAQNOn4+vhc5r2/HT iwfutJNqNnzzjUCBc+niUu7nTL2MhmRXSmWLpyEZQglsuPhh63tiq21m47SR4S/YiKnG 9+b+HZqP60L0F13sXn0ZYHS4g8Ztinpl2R0ulVi+sxbvDebvr8peukMIkqYEDCkZolC9 9zk1IhUwzTvqOfmTGBgSri8IJuiKdraaCwhgZyKRHep0aTvVEx1Shil1xigDs6gYYhwd lq9h45n8jpzyzZ/wDUXeq9fRLYzYErzRWfNkcS4h05AO6A2trdmjeOPAYZxRLlva9ESV DpNg== 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=lZkZnSeEV2aBth0eJSdVps7Xao5y4q9K+ndwh9cWYTg=; b=KbpUTwvdHVQh0qeDXOnqybe61BDytPOUeTRc6Tsa1m05cGL4HL30758ql2WB9pwhpH 4RDRqgL4QQl429uDHeRAttcOnZL/X0UG6e4mejWvQEvsDmSKfODtxQC6EzL/9/13n3Qw aYv2x8Yz2DRHM7S5AsChwt9g48jaJX3qm/dXYdcgk6DwBupKk4mPHyIU3eqSD4cClgmk IhN9d7HrJfo6QK7LoA5QWg4Rr9x/CMSNJpNGAdnUTnCJTwCf1G8LbIuEnYAKyWeU3AO1 00mdlnL1tw3tk5Ac3dYX4Tr1+36JkUtWeQhmXRdbtUb6A/8h2js6ANm3AtwXR+fkhcl8 tTKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=DguCHVoV; 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 n128si10673399pgn.15.2018.04.08.20.07.40; Sun, 08 Apr 2018 20:08:17 -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=DguCHVoV; 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 S932408AbeDIBy3 (ORCPT + 99 others); Sun, 8 Apr 2018 21:54:29 -0400 Received: from mail-sn1nam01on0094.outbound.protection.outlook.com ([104.47.32.94]:49836 "EHLO NAM01-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932271AbeDIAdM (ORCPT ); Sun, 8 Apr 2018 20:33:12 -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=lZkZnSeEV2aBth0eJSdVps7Xao5y4q9K+ndwh9cWYTg=; b=DguCHVoVrPRinkrxH+AyAdC0l0cnXAgvpkXfT5msCYMUMAMMBN1ND+r7jHHbh/NW7gWMyfBYZk2TukXpE8xof1R2ste9vbKrinKjOUAgV9HHpOVgdWlCxcwA9ntf05HOjN3oKG7kL8HVQVq+imMOyDqAnqxK3IFFmPZQH9/5kZc= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB0902.namprd21.prod.outlook.com (52.132.132.159) 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:33:07 +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:33:06 +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.9 235/293] mac80211_hwsim: fix possible memory leak in hwsim_new_radio_nl() Thread-Topic: [PATCH AUTOSEL for 4.9 235/293] mac80211_hwsim: fix possible memory leak in hwsim_new_radio_nl() Thread-Index: AQHTz5lT+ZTea2Sa/E6IaCyaZAmXDw== Date: Mon, 9 Apr 2018 00:25:56 +0000 Message-ID: <20180409002239.163177-235-alexander.levin@microsoft.com> References: <20180409002239.163177-1-alexander.levin@microsoft.com> In-Reply-To: <20180409002239.163177-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;DM5PR2101MB0902;7:Iflv/tUW2lQSACcg+Ye4+6ru5qWdCFQkpaBCYUy/xfzt1fQQhTqVRwkLmY3uu6IlO8DoIK2F9pjSlsONs7sbsHZ1l5LbgTw5NVWwI1BfVuxVejiBwBHN2brTfXyM6bXFczHG05j2vPS/S3bdztRWF/an/BqNzH1Me5ftXawloMSQY6IZgLLHMChVtSBV3JnKKnFBUq11kqDoy9AVffIRYMRwlnk3vbLUKxfUOkJQLWKEk81UaKvcFfFqttuL0Sr+;20:KB6oSQnN3sI7BTt67fszCRW4CP+wOSjJcAhYzckyj0xGrAVbnrdCD+fdK2Yee0XIL7wgHOTkMFi6uIUv7VPeiA9Ug8YNLR6QRR6vUJ2A0NKawHUhR7eTZcGfHXG6xwce/4d/TT/1pfrw/GNg7IvmNkhWFrHZcBkHUK9I1thgKtc= x-ms-office365-filtering-ht: Tenant X-MS-Office365-Filtering-Correlation-Id: 0554e8fb-42b1-468d-f0d8-08d59db176c0 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020);SRVR:DM5PR2101MB0902; x-ms-traffictypediagnostic: DM5PR2101MB0902: 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)(93006095)(93001095)(3231221)(944501327)(52105095)(3002001)(10201501046)(6055026)(61426038)(61427038)(6041310)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123564045)(20161123560045)(6072148)(201708071742011);SRVR:DM5PR2101MB0902;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB0902; x-forefront-prvs: 0637FCE711 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(366004)(376002)(396003)(39860400002)(39380400002)(346002)(199004)(189003)(5660300001)(478600001)(86612001)(3846002)(6116002)(106356001)(25786009)(6486002)(72206003)(10290500003)(8936002)(6436002)(76176011)(2616005)(6506007)(2900100001)(97736004)(26005)(486006)(10090500001)(36756003)(81166006)(8676002)(81156014)(59450400001)(102836004)(2906002)(99286004)(11346002)(476003)(3660700001)(66066001)(6512007)(575784001)(86362001)(53936002)(105586002)(186003)(5250100002)(14454004)(22452003)(6666003)(2501003)(446003)(7736002)(316002)(1076002)(110136005)(3280700002)(68736007)(54906003)(107886003)(4326008)(305945005)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB0902;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: fBvI6nezYOZTNVlckek+hv04DzKBJ9PH/ZkY2nZktE7ZFpHrZ9et65V9Euiile5M8OI0dWBwXUL0ENR92PAje18nAkXev+oID/3jFhyFGK6FvIJG8F/dBqGDNH4rotofd+5aZyBwwhbg2OCHoTxSDAr9ZW1hQNBciOhsoNjTe60DZnFEr4nTGM467kRhBIk+JR5D91zx5CaOk31XlNadm12v7z6R5Tgup+jhvxi4sN7ji++RkoIHYzyHcgSQ1n4kMJa7TLh/6r+Qc5fYkMY0lbc783GzJvt328CSHiw26GlNtuEnq79xVs0+s2A2jN7aofXtRK9X8jSwetJz7MzXVGhhxMMpoQ0Tb4ezqB3AEXABVkJMEQLLxmI42zgSCqoi9zyuYumwsnfeYmT6f6mpXGW4DMKUUwot6wDfTP8QYAg= 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: 0554e8fb-42b1-468d-f0d8-08d59db176c0 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2018 00:25:56.8317 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB0902 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 4182c3775a72..eb6a145d2ed6 100644 --- a/drivers/net/wireless/mac80211_hwsim.c +++ b/drivers/net/wireless/mac80211_hwsim.c @@ -3084,8 +3084,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