Received: by 10.223.176.5 with SMTP id f5csp1030104wra; Fri, 2 Feb 2018 10:00:20 -0800 (PST) X-Google-Smtp-Source: AH8x226ikyYVS58n44f0Xuw5FT2Z/mSP3tZ4RqvnBv8Z2HVXI5l3FLEPjreRN7KViQLy8aFuJISN X-Received: by 10.98.30.1 with SMTP id e1mr41034367pfe.37.1517594419904; Fri, 02 Feb 2018 10:00:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517594419; cv=none; d=google.com; s=arc-20160816; b=NGNlFSASxF+8U43BVFv1KUAOa7nt0m5c83mqFLvBws/ZjfMJQhEBJ1I8feGMAbQpdh +9xUptZjcpYcDyE50KcRx865LfjOGTS0H6XEdhflfSFslhebf+K7DSss7EQBb3+X63hj Aw6PCdx4KGVFfqv4yRd6/aHq9bK8LrBhCiO1XNmRNjxr0RXP/CI8loBaaecH7wCxGcTy rwPBQ35rTj2sNMxRMrm5hqOOHrAjd7HcvOMBf1JOmEswsPHrEVGmFp6JKMn2wizfPzVY flSVPFVJvhiKJEn9r+5NpUjyiRQbueSDP5L0AaImeIHgiQAj/ObUeQ0bLMYOXsYXgVxl /Xew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=O62YG1Sao71/DE5n9NvRgbkNn2NE4bB8iQ840O1dfs8=; b=dV3Qt/R0h4qZtIMx+0Eff4lXgJp04UthERsCkP2L2oLV3bddqkKzuAttID+57JsfoS th9jO6ZDwqtv4Je5bZE+HFQDvjw8X/BPFuJ5iSnp9v4xqPdnRCxoJDBEU3gxHWo2rfR6 zoojeLBs87KypVKhyh45bv5n6kYkV+2SThNrfjXVHk5eaivJ3JDxF9PjX5YnvGTv+ZN5 oXlyVLV2Y2BSQW3F4IsimGn33064jF2QnEhN5H9opADkwrPjXWFuBgXg3LAXaXWvb3NY dpplkf9LONNIXR7v21E1VlAjWU8zbF/BeicFsRK2i/qHCnUc8BJpL9m+7MXH9Yhe9DQj T6cQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e17si1713793pgo.189.2018.02.02.10.00.04; Fri, 02 Feb 2018 10:00:19 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753332AbeBBR6X (ORCPT + 99 others); Fri, 2 Feb 2018 12:58:23 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:38394 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753303AbeBBRKl (ORCPT ); Fri, 2 Feb 2018 12:10:41 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 96DFBEFB; Fri, 2 Feb 2018 17:10:40 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Colin Ian King , Wolfram Sang , Sasha Levin Subject: [PATCH 4.14 082/156] i2c: i2c-boardinfo: fix memory leaks on devinfo Date: Fri, 2 Feb 2018 17:57:43 +0100 Message-Id: <20180202140843.980784802@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180202140840.242829545@linuxfoundation.org> References: <20180202140840.242829545@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ 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_board_info()") Signed-off-by: Colin Ian King Signed-off-by: Wolfram Sang Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/i2c/i2c-boardinfo.c | 2 ++ 1 file changed, 2 insertions(+) --- a/drivers/i2c/i2c-boardinfo.c +++ b/drivers/i2c/i2c-boardinfo.c @@ -86,6 +86,7 @@ int i2c_register_board_info(int busnum, property_entries_dup(info->properties); if (IS_ERR(devinfo->board_info.properties)) { status = PTR_ERR(devinfo->board_info.properties); + kfree(devinfo); break; } } @@ -98,6 +99,7 @@ int i2c_register_board_info(int busnum, GFP_KERNEL); if (!devinfo->board_info.resources) { status = -ENOMEM; + kfree(devinfo); break; } }