Received: by 10.223.176.46 with SMTP id f43csp278450wra; Tue, 23 Jan 2018 20:55:24 -0800 (PST) X-Google-Smtp-Source: AH8x227o6WODwJAfXMCLNnZuEiRoF+DhCcQ/Wr28qSwStQ6pxU/gn1a1XH9XETjqK1zP4JVKi40O X-Received: by 2002:a17:902:6c:: with SMTP id 99-v6mr5082722pla.409.1516769724516; Tue, 23 Jan 2018 20:55:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516769724; cv=none; d=google.com; s=arc-20160816; b=CDKPAix45vCOPG62fYgV+ro65TutYPF+Lhgdzf3VcGePfcEcWTakVBfTNYRtchcQY/ eb5qSYEHA0PbkHKRjJHa3HoJ6gCVWDjMue7Y+5XpOsro4Bpj6BNIKRCRJrJ3iOrf7E8K YJFt0Y/pbJTxzy3Df5bGiQcqcDuNN6s9gBtuk29ZP8a8pcGa3vj7ExskMLrNlOJReHIv GL9ycd4uZbewGMr/kkR2Q01+NUXQhxTvQDeg4IkjzacyF1scLyRwlbSjJTMiz1OPCXox K9a3iRkn1JKNo52ZO0GQ3rFNxwXeMRQ0WkzwJj9HqVMY0ZSGvKKpztFVFJl60N5Ah+QV G2+g== 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=pHWXvZW1DR4UFZT79PqcHMg0DAvWtFm71jO7hyTUqUo=; b=o3avJ6zlrM3FpxdDilpSnFYalZDn8wWOKiqHCiPiFnwdOFoui61Y7qBXIddb+7ohts k/1qqs/NZX52UyMV+5kk8YmMmQLAn7MyIrxp4Kpm915I0otqmQndQzMGAe6d1ShMV/7k T/YZpOKeTAHVUnqe7/PSq0/0y2vHUR4z6zWcyWuBVcsarSX2y2gsZZwoujm55QqfxPz0 0fn8p0Z2rss6acdDLuy9RAf0D2k+rXZFH6lnBWuKq+79AUfPgEicM6uWdgCjtKK1kf1r qLsqEOaCSCS1h+RDewBZLGcllhXrqfhHznoFg/R5s2+lI8NPmVc8UTA+nVN85JsN3vuQ ji0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=MG52Qtd+; 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 o13si15362017pgp.740.2018.01.23.20.55.10; Tue, 23 Jan 2018 20:55:24 -0800 (PST) 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=MG52Qtd+; 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 S932247AbeAXEP2 (ORCPT + 99 others); Tue, 23 Jan 2018 23:15:28 -0500 Received: from mail-sn1nam01on0109.outbound.protection.outlook.com ([104.47.32.109]:45568 "EHLO NAM01-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932212AbeAXEPY (ORCPT ); Tue, 23 Jan 2018 23:15:24 -0500 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=pHWXvZW1DR4UFZT79PqcHMg0DAvWtFm71jO7hyTUqUo=; b=MG52Qtd+a+06VVpBgi1F4YqJ+hI8KDcTFocjKfn3q+1ZIRK//9it2mdADJeRtIlicTrMnCuct4k5anp43ojRT78u49jtlOuTvEPTz0M99KvgwZ0kW+aW+xuEf6zQBVcDLlLMRwixQZtP9qI3GUzyPdIoJ/RljkQNm4QcnOYJ/Nk= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB1015.namprd21.prod.outlook.com (52.132.133.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.464.0; Wed, 24 Jan 2018 04:15:18 +0000 Received: from DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::6485:b98:d15e:9da7]) by DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::6485:b98:d15e:9da7%2]) with mapi id 15.20.0464.000; Wed, 24 Jan 2018 04:15:18 +0000 From: Sasha Levin To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" CC: Colin Ian King , Wolfram Sang , Sasha Levin Subject: [PATCH AUTOSEL for 4.14 053/100] i2c: i2c-boardinfo: fix memory leaks on devinfo Thread-Topic: [PATCH AUTOSEL for 4.14 053/100] i2c: i2c-boardinfo: fix memory leaks on devinfo Thread-Index: AQHTlMnhgkwwnhZWtkKmFbCN8SrFTA== Date: Wed, 24 Jan 2018 04:14:51 +0000 Message-ID: <20180124041414.32065-53-alexander.levin@microsoft.com> References: <20180124041414.32065-1-alexander.levin@microsoft.com> In-Reply-To: <20180124041414.32065-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;DM5PR2101MB1015;7:GnbgpqbUmOwODR8z1AEiJfn3TAumjQXdQE07czCnH+dbfUDQbzfeSGjb7k2tnjgP/XuAwPvPS90p7MI/imY7JQfdUlk6HS361gMa4xw1LGOpdtFf2pAEs6zHNDVFhA1HkA0chtCu6FXJWAeihXnSfMELqg8nStr5kfBjK5vVCVmHojzbWaVSzaNeqTsyU6uyiGNBLZQ6in1dBTLgGhqp77MWJZQ2bPUrkQxCvxCPOmFkx2XteE2GC0oi9I3mCHwF x-ms-office365-filtering-correlation-id: cc5712e5-ea44-4dcf-515f-08d562e1143e x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(48565401081)(2017052603307)(7193020);SRVR:DM5PR2101MB1015; x-ms-traffictypediagnostic: DM5PR2101MB1015: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171)(198206253151910); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(61425038)(6040501)(2401047)(5005006)(8121501046)(3002001)(10201501046)(3231046)(2400081)(944501161)(93006095)(93001095)(6055026)(61426038)(61427038)(6041288)(20161123558120)(20161123562045)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011);SRVR:DM5PR2101MB1015;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB1015; x-forefront-prvs: 056297E276 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(396003)(39380400002)(376002)(366004)(39860400002)(346002)(199004)(189003)(478600001)(6666003)(106356001)(6512007)(53936002)(2900100001)(36756003)(102836004)(2950100002)(2501003)(10290500003)(97736004)(14454004)(81166006)(72206003)(8936002)(6486002)(1076002)(10090500001)(6346003)(26005)(54906003)(4326008)(76176011)(99286004)(86362001)(3660700001)(105586002)(6116002)(8676002)(5890100001)(68736007)(22452003)(66066001)(25786009)(6506007)(5660300001)(305945005)(7736002)(3280700002)(5250100002)(2906002)(107886003)(86612001)(6436002)(316002)(81156014)(3846002)(110136005)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB1015;H:DM5PR2101MB1032.namprd21.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-message-info: lxKUWmznI62ao+Rpi4LZB2lInjPdtdZEpEpk3WgRYI7wErmIN/Y8uKaKhFBuuJQCpdlRtVevN7lVsQ9rn3PAhg== 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: cc5712e5-ea44-4dcf-515f-08d562e1143e X-MS-Exchange-CrossTenant-originalarrivaltime: 24 Jan 2018 04:14:51.3129 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB1015 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Colin Ian King [ Upstream commit 66a7c84d677e8e4a5a2ef4afdb9bd52e1399a866 ] Currently when an error occurs devinfo is still allocated but is unused when the error exit paths break out of the for-loop. Fix this by kfree'ing devinfo to avoid the leak. Detected by CoverityScan, CID#1416590 ("Resource Leak") Fixes: 4124c4eba402 ("i2c: allow attaching IRQ resources to i2c_board_info"= ) Fixes: 0daaf99d8424 ("i2c: copy device properties when using i2c_register_b= oard_info()") Signed-off-by: Colin Ian King Signed-off-by: Wolfram Sang Signed-off-by: Sasha Levin --- drivers/i2c/i2c-boardinfo.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/i2c/i2c-boardinfo.c b/drivers/i2c/i2c-boardinfo.c index 31186ead5a40..509a6007cdf6 100644 --- a/drivers/i2c/i2c-boardinfo.c +++ b/drivers/i2c/i2c-boardinfo.c @@ -86,6 +86,7 @@ int i2c_register_board_info(int busnum, struct i2c_board_= info const *info, unsig property_entries_dup(info->properties); if (IS_ERR(devinfo->board_info.properties)) { status =3D PTR_ERR(devinfo->board_info.properties); + kfree(devinfo); break; } } @@ -98,6 +99,7 @@ int i2c_register_board_info(int busnum, struct i2c_board_= info const *info, unsig GFP_KERNEL); if (!devinfo->board_info.resources) { status =3D -ENOMEM; + kfree(devinfo); break; } } --=20 2.11.0