From patchwork Sun Aug 20 16:49:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 43364 X-Patchwork-Delegate: laurent.pinchart@ideasonboard.com Received: from vger.kernel.org ([209.132.180.67]) by www.linuxtv.org with esmtp (Exim 4.84_2) (envelope-from ) id 1djTPT-0002zE-Uv; Sun, 20 Aug 2017 16:49:12 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753170AbdHTQtI (ORCPT + 1 other); Sun, 20 Aug 2017 12:49:08 -0400 Received: from smtp11.smtpout.orange.fr ([80.12.242.133]:36788 "EHLO smtp.smtpout.orange.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753118AbdHTQtH (ORCPT ); Sun, 20 Aug 2017 12:49:07 -0400 Received: from localhost.localdomain ([90.21.44.83]) by mwinf5d46 with ME id zUp41v0081ngAYy03Up4Wp; Sun, 20 Aug 2017 18:49:05 +0200 X-ME-Helo: localhost.localdomain X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sun, 20 Aug 2017 18:49:05 +0200 X-ME-IP: 90.21.44.83 From: Christophe JAILLET To: mchehab@kernel.org, gregkh@linuxfoundation.org, arvind.yadav.cs@gmail.com Cc: linux-media@vger.kernel.org, devel@driverdev.osuosl.org, kernel-janitors@vger.kernel.org, Christophe JAILLET Subject: [PATCH] Staging: media: Release the correct resource in an error handling path Date: Sun, 20 Aug 2017 18:49:01 +0200 Message-Id: <20170820164901.9810-1-christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.11.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org 'res' is reassigned several times in the function and if we 'goto error_unmap', its value is not the returned value of 'request_mem_region()' anymore. Introduce a new 'struct resource *' variable (i.e. res2) to keep a pointer to the right resource, if needed in the error handling path. Fixes: 4b4eda001704 ("Staging: media: Unmap and release region obtained by ioremap_nocache") Signed-off-by: Christophe JAILLET --- drivers/staging/media/davinci_vpfe/dm365_ipipe.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/media/davinci_vpfe/dm365_ipipe.c b/drivers/staging/media/davinci_vpfe/dm365_ipipe.c index 6a3434cebd79..8d2d3f8edc07 100644 --- a/drivers/staging/media/davinci_vpfe/dm365_ipipe.c +++ b/drivers/staging/media/davinci_vpfe/dm365_ipipe.c @@ -1791,7 +1791,7 @@ vpfe_ipipe_init(struct vpfe_ipipe_device *ipipe, struct platform_device *pdev) struct v4l2_subdev *sd = &ipipe->subdev; struct media_entity *me = &sd->entity; static resource_size_t res_len; - struct resource *res; + struct resource *res, *res2; res = platform_get_resource(pdev, IORESOURCE_MEM, 4); if (!res) @@ -1805,10 +1805,10 @@ vpfe_ipipe_init(struct vpfe_ipipe_device *ipipe, struct platform_device *pdev) if (!ipipe->base_addr) goto error_release; - res = platform_get_resource(pdev, IORESOURCE_MEM, 6); - if (!res) + res2 = platform_get_resource(pdev, IORESOURCE_MEM, 6); + if (!res2) goto error_unmap; - ipipe->isp5_base_addr = ioremap_nocache(res->start, res_len); + ipipe->isp5_base_addr = ioremap_nocache(res2->start, res_len); if (!ipipe->isp5_base_addr) goto error_unmap;