Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp6126pxb; Fri, 15 Jan 2021 06:13:10 -0800 (PST) X-Google-Smtp-Source: ABdhPJyOFOhE81FKy/6tn6XQBFvAe3a+sscK35rbqzzuV5hThaCZlxTNoXzFdo7w1aref7TL06nl X-Received: by 2002:aa7:d2c9:: with SMTP id k9mr9713645edr.74.1610719990504; Fri, 15 Jan 2021 06:13:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610719990; cv=none; d=google.com; s=arc-20160816; b=oeDYDIHRU3nhVaC/WjV6RI9/i8oRUl6osZNbWKbhw0ZrzUUubD2EURVSCCagPGEvr3 TfPak9Mw55AsHkqwoYmUxnl8l6OotsyXXC/tAv47OSuqW/sLKBzXlBqATigDHzqTvoaf NXV7rde5r90jkGKiB5l0gnge+YnSyY0nrS/qW1KAePpGMVi7sqcNJTKDUZ5vkE3Ve2Nc dtEm9E5oZoH5YqUKKmgKo4aT+Ie3V2O85PYK+zWIdjBN2yHlfXhJCkWS6mLYGa89C4wN eoMSlRquj0tXchD6EH+pzrX9oy1cWxyudjFLL01jedfAjFVFOe5KziyD+oQWD72XvspW X3sQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=yVMDQ0NoHdwzCzsf38XWdiH+uvMyE/EInOhZIyF3pLo=; b=yP8wvyIo2vR56iA+D8Ip8dcBXHBoxUYD6qPr20dLOS++ErWVOuP5qbQyDEtg+N7pdg CJuUjjCPUYqayDeQf/UR9vQNUUDFFSqLS3oMPzhfzMS89VODKgWqzecbkPbInpFbmGoC 9YwtDZTutjK+a/HOU5qu3YujkGbgrYbKxhuq1nVhrKyu8uK+8E6XBQDxjsQQdvWlpjux i8M9HUPa6DhWoL0PwuDjVNHrfkxhwL+L7cTkNCjVQdj8xodNgZrXGPYdVQ7EPLZsngoH EYe3lW6BPDQn+iS+FBAAqN7qMXWWPwCvTi0lZWOBJxRjailT0ISgx6StSPbWWqOJ06HA xsfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=L9+njV6f; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z23si4473149edr.334.2021.01.15.06.12.46; Fri, 15 Jan 2021 06:13:10 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=L9+njV6f; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731945AbhAOOLk (ORCPT + 99 others); Fri, 15 Jan 2021 09:11:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60376 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729489AbhAOOLk (ORCPT ); Fri, 15 Jan 2021 09:11:40 -0500 Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 041CDC061757; Fri, 15 Jan 2021 06:11:00 -0800 (PST) Received: by mail-pj1-x1034.google.com with SMTP id md11so5132649pjb.0; Fri, 15 Jan 2021 06:10:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=yVMDQ0NoHdwzCzsf38XWdiH+uvMyE/EInOhZIyF3pLo=; b=L9+njV6fLMgwDoj3nkpi20rCK9v8g/jT8uOnoKDnpbOOLMATTVsSJLEAAYgTZQMQVq GlYGESYqvxmLJDkVbBmOumM/88YD05LfW+TRbh1YmKsCSAx546p/BsKf1sOB29cWyOTF 5j1nayyN5V86P3pT7YcqjxhIFsT/Vo0aIWhKl0R0e/M3NIP4gQYgQdOAK9LP9ftp5e4n /plzAuUVVQ1JZtHImRWI4DuhhH/zbHSFkFeffT6bWspn8DolVML8q4b+xxl5vpG0t2KA hCFM+rPQiaAS3IYAlvMvPvO02Qv+FcnYp80FnZIASHm4+CqGt9LyOGijf2mIIya9V0Mp NA8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=yVMDQ0NoHdwzCzsf38XWdiH+uvMyE/EInOhZIyF3pLo=; b=Hb2b2Ow8s2giKB9Azy8jSebK2rjppz7JlF3RjZbymyGGn0F/apLhvKiCX9Qp+654nM Biy2qM9YEslYgkUlGqt0trA7LuSRYATkTAocPKBwoyE72VBRQjQQ9mJmbqkbbY4vyfBX CJP/MDlDFofC/vE/qGlBE+uAj+E3kja3yhLllUq8p1h1YeKzd5TXt1sdeRDDQhP33DQ0 m52eBi4WV/yK4wi/zKIlPl23kyooCTyovOGCJq7IfxP9wyxmcYFiWdUbPfzMrEKSMk07 RRLhybTlRMT+UZTE9OuWZ0g7qhqivltRcoemxn/TY1EYrf4AikPTDwXHGAL1KPkAG8vQ Lt9w== X-Gm-Message-State: AOAM530Or+ZcIXG9dJFf8qRwgk8yqKicgQHP/xE58IN+fwTjqg6rEQgi Y+8ow4q5N4Q4cWsUmemi9JoJx028qaEm2KjBEeo= X-Received: by 2002:a17:90b:17c7:: with SMTP id me7mr10623511pjb.205.1610719859407; Fri, 15 Jan 2021 06:10:59 -0800 (PST) MIME-Version: 1.0 References: <20210115130911.71073-1-colin.king@canonical.com> In-Reply-To: <20210115130911.71073-1-colin.king@canonical.com> From: Sumera Priyadarsini Date: Fri, 15 Jan 2021 19:40:47 +0530 Message-ID: Subject: Re: [PATCH][next] drm/vkms: Fix missing kmalloc allocation failure check To: Colin King Cc: Rodrigo Siqueira , Melissa Wen , Haneen Mohammed , Daniel Vetter , David Airlie , dri-devel@lists.freedesktop.org, kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jan 15, 2021 at 6:39 PM Colin King wrote: > > 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 Good catch, thank you! Reviewed-by: Sumera Priyadarsini > --- > 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 > regards, Sumera