Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp3900965pxb; Mon, 21 Feb 2022 07:59:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJzUTQ+ksbjoF9cGUHse+j9gxheN2dm7rWxIkToJM/79dBB+Bhz9+Tmzy2SLdkuZC3IwIvJa X-Received: by 2002:a05:6a00:2387:b0:4e0:5414:da5c with SMTP id f7-20020a056a00238700b004e05414da5cmr20670091pfc.85.1645459181958; Mon, 21 Feb 2022 07:59:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645459181; cv=none; d=google.com; s=arc-20160816; b=zUfwsD09bNj6BIXpSQzgcFZhmpSX/A58CUl3bgW6oL+13nO/+mazPrivLqMkC7YaaR ApZq56xBSu4+0kbRgBBAQ7B2XgbgJnm+C8t1cu9VlajlWCGoqKcy2cQWBWV717OsmHL2 iTKLkCKAuOCBi3rm2Ljw88lAXGqelEaUqglXCOiSWCTLNxt2lizrjWTces1713QnCdWb chiAvnw+WLmRkQjYdCDxF3ud4ZjWDoqzX9vWWn6eIWlrNU4I7akmx64msOKk1hWZQ68e 6uRnTNnNKjhOiPkYdPWf5w9oJ8bkX9rM03anRC9KxkzSwgcw2xssF4CSCqUMSbmuXcLi MmKg== 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:date :subject:cc:to:from:message-id:dkim-signature; bh=4fADd5ckbj9wLsNGEkx/YWl2k1NstFX4D6yO2oX22N8=; b=Xwkf4OPJZ+Tq8ZSyw1hnAv4e040B0lgBSG4uSlzJqLVCdAyxaxern3d+D1Lx9g3udb VclRTkI/g/ZOjkD7vquRShB2eIpNtnjTX4QpQBThzO2GzbLazEM7S8vQmeevTHL8bKGZ 91grGEkQPSNuueJ0wxDGvFoaR/I+g8EvN/vx0FxHvu089E6NpgtCVC4jdo2FLKlQW1u6 2J1iNZLUIaVBEnRdDzKm1qDldGtm+++6yDfXFXm+eXCeMiP1SFnyBJx+EiXFfrufw2Kv BG3YO3uaNKYuqm/0Op5NutFrKarB4mU8cxeQzqALfeTYB6qgGUWuvHTTSlDAGTjBPqIH o+LQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@foxmail.com header.s=s201512 header.b=PHaq+c8C; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=foxmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 189si12202290pgd.553.2022.02.21.07.59.25; Mon, 21 Feb 2022 07:59:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@foxmail.com header.s=s201512 header.b=PHaq+c8C; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=foxmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355538AbiBULMh (ORCPT + 99 others); Mon, 21 Feb 2022 06:12:37 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:41056 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355758AbiBULMW (ORCPT ); Mon, 21 Feb 2022 06:12:22 -0500 X-Greylist: delayed 244 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Mon, 21 Feb 2022 02:45:55 PST Received: from out203-205-221-240.mail.qq.com (out203-205-221-240.mail.qq.com [203.205.221.240]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 47C2B24B; Mon, 21 Feb 2022 02:45:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1645440353; bh=4fADd5ckbj9wLsNGEkx/YWl2k1NstFX4D6yO2oX22N8=; h=From:To:Cc:Subject:Date; b=PHaq+c8CRFQrqVX1bOSiEyUc5E5SzgmuMEyyZILgJRJj3tUm3XaVHjvTOScJwOHYL etsu5zHu1SgZ+rSKgDOfJczgsZSNwsgHr/9FWbVRGa37dpKGrsiii9yw3jbm+0kLtm DFkqRoWjSchefQtg1j5YWKviVYN7wSk2aVD3hgWA= Received: from localhost.localdomain ([218.197.153.188]) by newxmesmtplogicsvrszc8.qq.com (NewEsmtp) with SMTP id 9A09E009; Mon, 21 Feb 2022 18:38:32 +0800 X-QQ-mid: xmsmtpt1645439912ty8r1galu Message-ID: X-QQ-XMAILINFO: Mx0gLVTpyl5nsAzj444ETocQ8S8QzHpdIe2WK5gE/ckWOfMwwiPqe8ilfBIyK6 ObfwC/6GBi8sc4OCc/rKxo8kHDrLFR39OPI7aep7JK2Lj3eo+I1GX/hvMMNq4hhurBjTJKIFHK/H WbF/gDL8p9JT5N23RdNegZchcVNYTWzf8eS2qWoVkMnsKG+ZlB87nPPh7ZbK9tJgxFTELA4LCf+H 0xL74nJKSyx6osOoKUKZWAL+L6d4wpRHKvQ3kHbtVbWmjDvOkJ2Zlat22wAwfAYdkfToo444yH3h deSvFU5NrEmQyqcof17yIOEM1vZ7z+BZ8/rJnrqqRJiScLFK5LUPqjhazqEQxrf2amQUAj6iCSDa JtHIvZo8PkoU9VnoUe+c7Z/aRV++LMv6OJGTxJwfZRtfDoI+gNmIx1iRIyk3eX5Ezqy8FqyIMzSE 4ZPBKp3eJ8M8jBNtWIA9uU9KCzQ/Zkpbax/DgyE0y7gB1m6OVbGRoucVLo060+SsLTUy/uexUDgG BtM71IXXh9mKwXkIsT3RK0HNMom+DsArAilPfTkUPnUiRmwwDHOrDQ2VORWY0+W9Z2hh2pdXybWb /vw6tTGs0TV1IIMO17Qi/QcfgRZJFDJg3bh2B+QLrsigS7Z4Fag8fxO0Mgym1ePPVOFyxqZKnsWa qR2uC1AQbiDBA4/kIsUTSlIRUbys1qMFnQmslLjQMOG8328ncJdv7slSUeGpB4VMPVORbHdLYfL5 QhV8WZKygAu3hs1cfxeXX3FhAVEamIoHOtX6GkTKgs8D2dgkTUM0tXU8kCJd0CzQ6VVyGwcHz3w2 A2ASV9jox6ygtf8UmdYqANgxEryX8GxMeSwMNzdSI02uPhUXR7rHqfOz5bUZGG1MoVL7qitnRTkM GdjFO0xNBd From: xkernel.wang@foxmail.com To: FlorianSchandinat@gmx.de Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Xiaoke Wang Subject: [PATCH] video: fbdev: via: check the return value of kstrdup() Date: Mon, 21 Feb 2022 18:37:34 +0800 X-OQ-MSGID: <20220221103734.3394-1-xkernel.wang@foxmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, HELO_DYNAMIC_IPADDR,RCVD_IN_DNSWL_NONE,RDNS_DYNAMIC,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Xiaoke Wang kstrdup() is a memory allocation function which can return NULL when some internal memory errors happen. It is better to check the return value of it to catch the error in time during the setup of viafb. Signed-off-by: Xiaoke Wang --- drivers/video/fbdev/via/viafbdev.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/video/fbdev/via/viafbdev.c b/drivers/video/fbdev/via/viafbdev.c index 22deb34..2d67c92 100644 --- a/drivers/video/fbdev/via/viafbdev.c +++ b/drivers/video/fbdev/via/viafbdev.c @@ -1939,8 +1939,12 @@ static int __init viafb_setup(void) if (!strncmp(this_opt, "viafb_mode1=", 12)) { viafb_mode1 = kstrdup(this_opt + 12, GFP_KERNEL); + if (!viafb_mode1) + return -ENOMEM; } else if (!strncmp(this_opt, "viafb_mode=", 11)) { viafb_mode = kstrdup(this_opt + 11, GFP_KERNEL); + if (!viafb_mode) + return -ENOMEM; } else if (!strncmp(this_opt, "viafb_bpp1=", 11)) { if (kstrtouint(this_opt + 11, 0, &viafb_bpp1) < 0) return -EINVAL; @@ -1969,6 +1973,8 @@ static int __init viafb_setup(void) return -EINVAL; } else if (!strncmp(this_opt, "viafb_active_dev=", 17)) { viafb_active_dev = kstrdup(this_opt + 17, GFP_KERNEL); + if (!viafb_active_dev) + return -ENOMEM; } else if (!strncmp(this_opt, "viafb_display_hardware_layout=", 30)) { if (kstrtoint(this_opt + 30, 0, @@ -1995,8 +2001,12 @@ static int __init viafb_setup(void) return -EINVAL; } else if (!strncmp(this_opt, "viafb_lcd_port=", 15)) { viafb_lcd_port = kstrdup(this_opt + 15, GFP_KERNEL); + if (!viafb_lcd_port) + return -ENOMEM; } else if (!strncmp(this_opt, "viafb_dvi_port=", 15)) { viafb_dvi_port = kstrdup(this_opt + 15, GFP_KERNEL); + if (!viafb_dvi_port) + return -ENOMEM; } } return 0; --