Received: by 2002:a17:90a:88:0:0:0:0 with SMTP id a8csp39038pja; Fri, 22 Nov 2019 03:09:59 -0800 (PST) X-Google-Smtp-Source: APXvYqwcif/fHr6j32sxhcfAWC+xKR95gNOEJ3MD21SmoDZUHnqo63f7hJPJTk/PwK1tYAR3LkEo X-Received: by 2002:a50:84e9:: with SMTP id 96mr334951edq.182.1574420999503; Fri, 22 Nov 2019 03:09:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574420999; cv=none; d=google.com; s=arc-20160816; b=jWUntTgxLesC+Pnzy7SfqczfwAN54DsAe7de0cxboTsWtfn4CVu/UQiGm36ktjygY7 HiUncD9vtnRyfuz5qvMHKn995lza7SU81RQEM2Igtzm5SZKLp6vJHncQJ/FUwOVMMdqe JVC04fawC3gUFr9CvVQFjtQqmhL59LMiYFg3YtMNWBGjfxVi/OMnFK+JnjjSLxx5q+7/ 8HbXF0RbJtpbE9QYUqsmZGiK4hyAKHjlnCAvI8fRU0IZVafmS8MUx8iBFKnKihIkUduv DiUudQUO5spZM6MKU6SCBSvbFokRNcQwq3/OdkZCXHsR3nt0hRk6I+psXsDhEyYVoOlw ISYQ== 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=7Rz9uiezO2dUJ4Czsbi8fhdUIda7qaT11t7wTBLoNoQ=; b=dAh5MTessm6qZ53dnWaOqW6UIAsm2OhXfY/6RF1M8AYAUykGl1P4iNZ3D8gTDf38sQ viYhUZyFXLfQJgB64nM23B6ZRy6UIR/0yw71jeb78GEoqkC/x4cQ2mfY/KN2KUhbJyRf TQCdXmo/GDVu+T3r04M0jFmmoQ7XHil2aM2N/fTMZZlaORhfY6GfCUDEAqOOlJ17Ci8w fKuN+Q8gSYNbrOyE9thHzn7g8sfxgt+Mg47acffU7vRv4gcFhPmkZPLVfxjTjZ4NFUao /7BV8EtlFEI0ITc9Uf4pc3tAsqStj8fmuRLICge10laj8qdx8MB26SHx6UyR2GfNCNcQ 3hTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ra9TBkug; 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 b6si2203048edb.189.2019.11.22.03.09.35; Fri, 22 Nov 2019 03:09:59 -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=ra9TBkug; 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 S1731187AbfKVLGJ (ORCPT + 99 others); Fri, 22 Nov 2019 06:06:09 -0500 Received: from mail.kernel.org ([198.145.29.99]:34076 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727881AbfKVLGF (ORCPT ); Fri, 22 Nov 2019 06:06:05 -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 47DB52088F; Fri, 22 Nov 2019 11:06:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574420764; bh=+G/Hb5yXy8J1/R9Fa07bK3eEpG/8DlxjsJp1lvjGrEM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ra9TBkugYUTA2u867sVtjjk76fKvuRiDYYqZb/SA7E/Pb19s548K4L4oHGeShcI5g Af6DDaBYBNI12Oqly+tyuMxG5lTcXUDekVVmmqDHjoZu/lvQK3M3S5ZrOupHpz7QAG sWbytJXJgB8E4VrBQ+6ZS6YMYUUVhhESGSexnboA= 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.19 174/220] media: isif: fix a NULL pointer dereference bug Date: Fri, 22 Nov 2019 11:28:59 +0100 Message-Id: <20191122100925.367404978@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191122100912.732983531@linuxfoundation.org> References: <20191122100912.732983531@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 f924e76e2fbf8..340f8218f54d3 100644 --- a/drivers/media/platform/davinci/isif.c +++ b/drivers/media/platform/davinci/isif.c @@ -1100,7 +1100,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