Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp655212pxv; Thu, 15 Jul 2021 12:36:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxKanJnc7UWMkBCfoDE85KYmff1VGJAKMIgx72tT7y+Hr1LHylY2/NPdb2OTNxjgz1nx5Ju X-Received: by 2002:a17:906:2590:: with SMTP id m16mr7243688ejb.265.1626377795063; Thu, 15 Jul 2021 12:36:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626377795; cv=none; d=google.com; s=arc-20160816; b=zi46fJ1aOX4guOEpKe2LECFxZXXr1aOlnbrN/Wbex2yFQpAXXhrGLkpZiDqJnXTTEa ypjmWRUQzDqUgCEo3/77g79YNqmlY/7luufVcciKbQv7iIXUehULj1yk1Om+Xh2TTmqq DzEBez0r2jz5k4jM/OZSHAovsmMv13wEybbO1cTbYIjHearGc0wYnG8SomRO3JqpSOON cwuPHO27MeiOU1bdW/a9mfTnf5uOzUgDXE1RSNopCIcIjRQghIVZkYy7bQr6njwb9r00 y2usOu1nAQk/Yza5giQuefKwOIHkeK7vdn952jaIvusFhxVGobytbUfz7eUPINyJLEm0 QbBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=h6JZdQrFqkISDo78un1njuOwPxN6UEEcYOJot5PvmTc=; b=zHA7gQgco5s/eXihkGUp9+Riu5dih5gJHk7+ao49e0zU3QfR4tJZ7sYLCQ6c6L4k/X o0FyGTPtj8G5rD0ww88tuZT/ZybL0Gtrv/7V5D5Ekbq4quAlVgZNzKYjJlX+EAa+Oom1 d/XwXvWJGtoC0xrZ9461/fSQEzKmJ12Tb4W1coAUPZv608WvrtE71XsN4yIABC4e6PcD uNSgXG7Qfs5C2bRIynR+IHpaKpwgn3ajiaef6H6vu6KCg7wXg33C+9fLayHY1Z1NtHIb zaRaIJACQmkQSVYcLkXMt/mLyhN6ka35LwaCDKcY87ow+QwPitZEi+lZIx/DugKEetbd FrNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=yT51gURq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f19si7884756edf.525.2021.07.15.12.36.12; Thu, 15 Jul 2021 12:36:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=yT51gURq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343573AbhGOTdV (ORCPT + 99 others); Thu, 15 Jul 2021 15:33:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:50134 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242112AbhGOTK7 (ORCPT ); Thu, 15 Jul 2021 15:10:59 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5C9DE60FF4; Thu, 15 Jul 2021 19:08:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626376084; bh=lBjcw4sOunxgl3Hqp9I4bME8z73756FTDxGKXLgCxdw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yT51gURq/YXxXSOTFlZrTgAvZLpffqJoSl+T3vFHqMVRnYnvac/7HubYIJv8c5cFu rA7sDM2OwHhbdEls5xj/xtgocFtEcUrWVUp5oaxsh9OlrT6/EbwzVzxzKk8YfuxC0K HRjgJK1I/zB/kxC3zndKJJbrfEVSERtccfj3TPOs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yang Yingliang , Vladimir Oltean , "David S. Miller" , Sasha Levin Subject: [PATCH 5.13 077/266] net: mscc: ocelot: check return value after calling platform_get_resource() Date: Thu, 15 Jul 2021 20:37:12 +0200 Message-Id: <20210715182627.747390040@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210715182613.933608881@linuxfoundation.org> References: <20210715182613.933608881@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yang Yingliang [ Upstream commit f1fe19c2cb3fdc92a614cf330ced1613f8f1a681 ] It will cause null-ptr-deref if platform_get_resource() returns NULL, we need check the return value. Signed-off-by: Yang Yingliang Reviewed-by: Vladimir Oltean Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/dsa/ocelot/seville_vsc9953.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/net/dsa/ocelot/seville_vsc9953.c b/drivers/net/dsa/ocelot/seville_vsc9953.c index 84f93a874d50..deae923c8b7a 100644 --- a/drivers/net/dsa/ocelot/seville_vsc9953.c +++ b/drivers/net/dsa/ocelot/seville_vsc9953.c @@ -1206,6 +1206,11 @@ static int seville_probe(struct platform_device *pdev) felix->info = &seville_info_vsc9953; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!res) { + err = -EINVAL; + dev_err(&pdev->dev, "Invalid resource\n"); + goto err_alloc_felix; + } felix->switch_base = res->start; ds = kzalloc(sizeof(struct dsa_switch), GFP_KERNEL); -- 2.30.2