Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp3684725imm; Mon, 6 Aug 2018 08:52:35 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfQQeonu1DxiVldN/oV63kyxqMRxRw4EJJS4OhcFXHiQCDWzd23gnSERZmT2WVtaNnCXsPh X-Received: by 2002:a63:1a49:: with SMTP id a9-v6mr15513769pgm.423.1533570755548; Mon, 06 Aug 2018 08:52:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533570755; cv=none; d=google.com; s=arc-20160816; b=RUle6S8d2MCTDQsKThuWArZ59WrEK1a1PKQBe33FnwBJu3urYTHjvZRGMQI11UYZ87 KEZvXU9E2/cKd60fJPPrR7ntpS2Ri2g8u80XPJ6K6vo2sNA73nSHW5VbEZdh4ssxCcXY F3PNyp0PV/6d3gCRZUOPvwrXqK9Mil7Dk+cvDJTH3V7JWVUdIfMEf8nvd7Vb8wztkMjr bxv1b+7pNhYqd3qScsQ1O57aMwal9FVUqxkFKaqPi3Plft1hOJTZrhtiE71LEh8+FncT imiyHhwake8Hr2imLzFBsIVY+xvE4y+XdcDo50khh1yxzYHOHKEpEG9+XwOfBQBcQwd6 EKMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=iV5woJUu9/OAGkj+nKlceScSueG9Zwu6zpxlCBXSbQI=; b=I8Snp77FF8FrBT7DdOulk8S8P6csrJri76WIlKXpMR8OxvBNKkO95JiCamljo/zuDC /K4I4W/sJ2l1Kw8d0EKqxvGJlNfgIsD6i7+xsTTlYcx0q7bf7QVSppgDg3cgwclUOlQQ lV60AO79zWKWdj3/Kf4kQ0PJgiN/6QQtGPm92GfwjS6PIJg1MJhlfUAooJ9606FmvcQr XATvFUezBiztwOY3fy4dOBBIleP8OjJWhiwlp7uglgCwbAYdzuwOlF6pH2mecqtgPmLH d9uG2rHcgsRBIj5866TxeG2dkl0YEBWNkIOOjzyE1s0dvA18SoDa9f0KVbAqxwUnkZEo ru2Q== 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 63-v6si12847511plb.288.2018.08.06.08.52.20; Mon, 06 Aug 2018 08:52:35 -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; 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 S1733012AbeHFSAh (ORCPT + 99 others); Mon, 6 Aug 2018 14:00:37 -0400 Received: from bran.ispras.ru ([83.149.199.196]:23653 "EHLO smtp.ispras.ru" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728626AbeHFSAh (ORCPT ); Mon, 6 Aug 2018 14:00:37 -0400 Received: from myklebust.intra.ispras.ru (unknown [10.10.2.207]) by smtp.ispras.ru (Postfix) with ESMTP id 20806203C7; Mon, 6 Aug 2018 18:50:53 +0300 (MSK) From: Anton Vasilyev To: "Lad, Prabhakar" Cc: Anton Vasilyev , Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, ldv-project@linuxtesting.org Subject: [PATCH v2 1/2] media: davinci: vpif_display: Mix memory leak on probe error path Date: Mon, 6 Aug 2018 18:50:24 +0300 Message-Id: <20180806155025.8912-1-vasilyev@ispras.ru> X-Mailer: git-send-email 2.18.0 In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If vpif_probe() fails on v4l2_device_register() then memory allocated at initialize_vpif() for global vpif_obj.dev[i] become unreleased. The patch adds deallocation of vpif_obj.dev[i] on the probe error path. Found by Linux Driver Verification project (linuxtesting.org). Signed-off-by: Anton Vasilyev --- v2: divided the original patch into two and made stylistic fixes based on the Prabhakar's rewiev. --- drivers/media/platform/davinci/vpif_display.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/davinci/vpif_display.c b/drivers/media/platform/davinci/vpif_display.c index 7be636237acf..d9e578ac79c2 100644 --- a/drivers/media/platform/davinci/vpif_display.c +++ b/drivers/media/platform/davinci/vpif_display.c @@ -1271,7 +1271,7 @@ static __init int vpif_probe(struct platform_device *pdev) err = v4l2_device_register(vpif_dev, &vpif_obj.v4l2_dev); if (err) { v4l2_err(vpif_dev->driver, "Error registering v4l2 device\n"); - return err; + goto vpif_free; } while ((res = platform_get_resource(pdev, IORESOURCE_IRQ, res_idx))) { @@ -1314,7 +1314,9 @@ static __init int vpif_probe(struct platform_device *pdev) if (vpif_obj.sd[i]) vpif_obj.sd[i]->grp_id = 1 << i; } - vpif_probe_complete(); + err = vpif_probe_complete(); + if (err) + goto probe_subdev_out; } else { vpif_obj.notifier.subdevs = vpif_obj.config->asd; vpif_obj.notifier.num_subdevs = vpif_obj.config->asd_sizes[0]; @@ -1334,6 +1336,9 @@ static __init int vpif_probe(struct platform_device *pdev) kfree(vpif_obj.sd); vpif_unregister: v4l2_device_unregister(&vpif_obj.v4l2_dev); +vpif_free: + for (i = 0; i < VPIF_DISPLAY_MAX_DEVICES; i++) + kfree(vpif_obj.dev[i]); return err; } -- 2.18.0