Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp33672pxb; Fri, 15 Jan 2021 05:12:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJxRIqEQQdKSJOHax0VCmOGSiH5dcO3YhP6LfL1AKI1ovaLmR3pMGUlr+mfeK/gbw5owh1I1 X-Received: by 2002:a17:906:7689:: with SMTP id o9mr8938525ejm.324.1610716367484; Fri, 15 Jan 2021 05:12:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610716367; cv=none; d=google.com; s=arc-20160816; b=tLKvFtGS1yHJeOZNN+VDosOvVtZzNtqlc7phiLV+cV7caqo2b+fuzWqNqOmjsTwgUH vUr4bXl1fbf2fgf+9a6KHkVXDE9bPl23YE0gBG4hZ8DSgM9jb8L7TudMmP6ZKRwQuoLd 4V/Z2LBmpryVMG2xVCjqMh+124S1I3qgsT4Alv5Zcy+5fB+a+i334THndtY2SXYBUj2z 5S9SvuoRfmIOOJ8RmInSmZNZyn3m167PQeYy4QMkkguFQ37kHhWMogpOd/JbvZ0LS6G7 YkpmrNtCMd8B9ALabfjcpLWi68TI/kOJgJptbUPwtCv795/XIbOt6vhlDTK5TX1DLuqD dDTw== 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 :message-id:date:subject:cc:to:from; bh=4sK7YP3eJiRsI2ZW62ham2bMSQLvdnk4r7R25LItvdQ=; b=mqAItQGCWyO1ygbMKbvb8tZ7ygbsSjBRrq1gXry4uLX+xHcYajk+d4PcbXdkJYmuFY k1IU82TPhH7JCCfS/E53dzLxtwx/fsiBmWffFtgxflc+Ptk8g2oMHOKZT7iNI5QIv/kj V40HekNfX6e1Xim/K2Olz/j/MMqKoW082r/EXZCzjYuGND0U39zZpooFBY1czI18R/Vh HNCenLsenvJlK9w8kZXeuHAyKUI1JC2z45oIcuUAqICnhQ27YmhT16PH6GhjHFzIkbZl B0ja2kXRoiU+BePWI8A9i9HV5usYfCMEW5/9Dl6sqSAcpZBz24/IjxZsHsFjQ2eVd636 rnog== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dm18si3837085edb.422.2021.01.15.05.12.23; Fri, 15 Jan 2021 05:12:47 -0800 (PST) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731315AbhAONLz (ORCPT + 99 others); Fri, 15 Jan 2021 08:11:55 -0500 Received: from youngberry.canonical.com ([91.189.89.112]:41806 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732537AbhAONJz (ORCPT ); Fri, 15 Jan 2021 08:09:55 -0500 Received: from 1.general.cking.uk.vpn ([10.172.193.212] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1l0Oqm-0001DP-5Q; Fri, 15 Jan 2021 13:09:12 +0000 From: Colin King To: Rodrigo Siqueira , Melissa Wen , Haneen Mohammed , Daniel Vetter , David Airlie , Sumera Priyadarsini , dri-devel@lists.freedesktop.org Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH][next] drm/vkms: Fix missing kmalloc allocation failure check Date: Fri, 15 Jan 2021 13:09:11 +0000 Message-Id: <20210115130911.71073-1-colin.king@canonical.com> X-Mailer: git-send-email 2.29.2 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: Colin Ian King Currently the kmalloc allocation for config is not being null checked and could potentially lead to a null pointer dereference. Fix this by adding the missing null check. Addresses-Coverity: ("Dereference null return value") Fixes: 2df7af93fdad ("drm/vkms: Add vkms_config type") Signed-off-by: Colin Ian King --- drivers/gpu/drm/vkms/vkms_drv.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/vkms/vkms_drv.c b/drivers/gpu/drm/vkms/vkms_drv.c index 708f7f54001d..2173b82606f6 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.c +++ b/drivers/gpu/drm/vkms/vkms_drv.c @@ -188,7 +188,11 @@ static int vkms_create(struct vkms_config *config) static int __init vkms_init(void) { - struct vkms_config *config = kmalloc(sizeof(*config), GFP_KERNEL); + struct vkms_config *config; + + config = kmalloc(sizeof(*config), GFP_KERNEL); + if (!config) + return -ENOMEM; default_config = config; -- 2.29.2