From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ED2B5FBEA for ; Mon, 15 May 2023 17:04:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F3DB6C433D2; Mon, 15 May 2023 17:04:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1684170273; bh=FbnlYb/vQ90ju0cjmiHeW3y/SIWacZiFnA5aAqR35WY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nVeaLxon2Wqq7OpJbC+JYBVCeNunI+m1JmStW+E42pQl/ZxayDqW89QI9NM5qn5jt e3aio2ulJsfgli8TFqCwqomo2jszbhPZZaYs8L8BgrAxMt3DybSaerVz2oP59Ir13x 96BAtb0RMFd8Wn7kg6Vs36qXm3UZKeaAlnPRoJ5k= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Shannon Nelson , Simon Horman , Jiri Pirko , "David S. Miller" , Sasha Levin Subject: [PATCH 6.1 078/239] ionic: catch failure from devlink_alloc Date: Mon, 15 May 2023 18:25:41 +0200 Message-Id: <20230515161724.024135758@linuxfoundation.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230515161721.545370111@linuxfoundation.org> References: <20230515161721.545370111@linuxfoundation.org> User-Agent: quilt/0.67 Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Shannon Nelson [ Upstream commit 4a54903ff68ddb33b6463c94b4eb37fc584ef760 ] Add a check for NULL on the alloc return. If devlink_alloc() fails and we try to use devlink_priv() on the NULL return, the kernel gets very unhappy and panics. With this fix, the driver load will still fail, but at least it won't panic the kernel. Fixes: df69ba43217d ("ionic: Add basic framework for IONIC Network device driver") Signed-off-by: Shannon Nelson Reviewed-by: Simon Horman Reviewed-by: Jiri Pirko Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/pensando/ionic/ionic_devlink.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/ethernet/pensando/ionic/ionic_devlink.c b/drivers/net/ethernet/pensando/ionic/ionic_devlink.c index 4297ed9024c01..2696dac21b096 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_devlink.c +++ b/drivers/net/ethernet/pensando/ionic/ionic_devlink.c @@ -65,6 +65,8 @@ struct ionic *ionic_devlink_alloc(struct device *dev) struct devlink *dl; dl = devlink_alloc(&ionic_dl_ops, sizeof(struct ionic), dev); + if (!dl) + return NULL; return devlink_priv(dl); } -- 2.39.2