Received: by 2002:a17:90a:88:0:0:0:0 with SMTP id a8csp17380pja; Fri, 22 Nov 2019 02:52:25 -0800 (PST) X-Google-Smtp-Source: APXvYqx8R5oOGP2YwLWwkCE8jmjrHan+IMeyqEP5JofOYmvWWwttPitnXY+XPR9Zs39tDomCf0sD X-Received: by 2002:a17:906:4a43:: with SMTP id a3mr20758240ejv.311.1574419945225; Fri, 22 Nov 2019 02:52:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574419945; cv=none; d=google.com; s=arc-20160816; b=ynmmRVTUjbAlat7dcGsTmAf7pxfw62lg+uN67JBS3nzPekTceiD0v4pXt4oozzMpLz IsfXcdFD8z4jkllpRjOISQkAaerKZYnf4L778/hoq2U59c2Lba9sXIwQMCnyfQAnn4YY CYzNoD1YQbTAt4QPH4MvkEjcRD6BSRfducitMOvBg6zwbxn1wQSiiDbCZvqt+LpMkKqw MyMIDnLMmxeEAiQSSW0OPj/cUoXduDbXN5fWmy9hK/xP01sAeQ8FlUBRLg4htYYaqcxJ Nu95RFVgHS+e+7aqVlva5iHOU3PTz7ckFXiAmbduBg3mgajxEF9qDJ3PX+ptyuI3mDMk x4uQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=KubJ5o5o+WLElLiCawauhPOKH/fvp0cyQK9nc1I2XpM=; b=scEZSJNFalMSdCtmOrhdh//pEoX2gSZ48fwOawRc16G2Oa3TDY3P55R5HlrQFHCfFf a+0T3ELdZv4GZWhJs5g28JLJMCQ962uo86bH3lYaPU26dy+I3AyokgjVWEwy4y6Vgy9u Qvt11i1d2heMFUNSeSBI/hiMFT1dl/v+g8oG7hgYtd2ZtU3ElxrPaP1Gvf87Br2aw1OU 56Xdeno02qADOAI3GKfGblw21oYNBig7JrzklsZF21ENHOvOnAYgqAshaJsXvYzlYXPI ByeMDhfdUPjKaZiImp+CmnQeLDMhpfdGH4WJdf++khJmWJfYwNq04D+oQ/XaJYli3d4v nrfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="AVvn/dwt"; 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 l23si3934200ejc.116.2019.11.22.02.52.01; Fri, 22 Nov 2019 02:52:25 -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=@kernel.org header.s=default header.b="AVvn/dwt"; 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 S1727468AbfKVKsr (ORCPT + 99 others); Fri, 22 Nov 2019 05:48:47 -0500 Received: from mail.kernel.org ([198.145.29.99]:57708 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729159AbfKVKso (ORCPT ); Fri, 22 Nov 2019 05:48:44 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id CEAA420637; Fri, 22 Nov 2019 10:48:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574419724; bh=jIJzKKrRiPN4sYSrKyogbBy6hg42/byJJuVxrEWKYyQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AVvn/dwte8GjJhmmBAJ5Gnv6PLpv0j3HX6pABAqRphyKhtQOf0yQ6IxAfdQ36iCyS wrZIoW5uIB3DSxtMtl51PLpiBqOwxKZefh9h6NTblIqfBfMqMnPsYw+46mO4FUlqWq vw75FWLfNP0S2WxKTVaD+Ns4xWv/cipOwVZK3H1M= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Wenwen Wang , Hans Verkuil , Mauro Carvalho Chehab , Sasha Levin Subject: [PATCH 4.9 208/222] media: isif: fix a NULL pointer dereference bug Date: Fri, 22 Nov 2019 11:29:08 +0100 Message-Id: <20191122100917.353814632@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191122100830.874290814@linuxfoundation.org> References: <20191122100830.874290814@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Wenwen Wang [ Upstream commit a26ac6c1bed951b2066cc4b2257facd919e35c0b ] In isif_probe(), there is a while loop to get the ISIF base address and linearization table0 and table1 address. In the loop body, the function platform_get_resource() is called to get the resource. If platform_get_resource() returns NULL, the loop is terminated and the execution goes to 'fail_nobase_res'. Suppose the loop is terminated at the first iteration because platform_get_resource() returns NULL and the execution goes to 'fail_nobase_res'. Given that there is another while loop at 'fail_nobase_res' and i equals to 0, one iteration of the second while loop will be executed. However, the second while loop does not check the return value of platform_get_resource(). This can cause a NULL pointer dereference bug if the return value is a NULL pointer. This patch avoids the above issue by adding a check in the second while loop after the call to platform_get_resource(). Signed-off-by: Wenwen Wang Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/media/platform/davinci/isif.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/davinci/isif.c b/drivers/media/platform/davinci/isif.c index 99faea2e84c6b..78e37cf3470f2 100644 --- a/drivers/media/platform/davinci/isif.c +++ b/drivers/media/platform/davinci/isif.c @@ -1106,7 +1106,8 @@ static int isif_probe(struct platform_device *pdev) while (i >= 0) { res = platform_get_resource(pdev, IORESOURCE_MEM, i); - release_mem_region(res->start, resource_size(res)); + if (res) + release_mem_region(res->start, resource_size(res)); i--; } vpfe_unregister_ccdc_device(&isif_hw_dev); -- 2.20.1