Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp4572315pxb; Tue, 22 Feb 2022 01:31:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJzmLC+IlUkPg3zfeMqtn2I3kjLzSFwIeX0nz52PJzpOJvWo6GTK4IbOsUm+5OfQEGFQPAsN X-Received: by 2002:aa7:ce92:0:b0:40f:b89c:18fe with SMTP id y18-20020aa7ce92000000b0040fb89c18femr25696637edv.67.1645522296240; Tue, 22 Feb 2022 01:31:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645522296; cv=none; d=google.com; s=arc-20160816; b=QgJDe1Oqh/bNdmoa186ctlZ8FXPuOp4Na+jR5RLMascU8g7mlE42ULqKlFTyW0fDeX L9o8dTVOLBhTVRn7icEadpUkYfJdCERuF2nmySVVL7/gfZiM91T6q5P2Wl4CErmWP/nx kFbARmBKVmq7QDTcurDzZr/2dCDk8TTpqnEcfBARTvHNKHo3llNc+x6z12GHOazF1WK7 onJ4BCEBrVfCrKOS++S9/VvkoosDxfn59n0gQcDfNkjYdcA1SDp9o/umGAsP5IzgkMqw nw5+rWNy0LEUcL6GxJtelvb3cguRVEleRkC1CfX9SYWpTdBr5gnHsp7rfTkIaacBzvqt a6bQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=EyBRfFLG9cmDCyyMBzYmNuUvcgWGDXrkDOl+D2H+zR0=; b=abg8yaUOiUCWRQgq1w+UPwhBQXBomh+eLCvMgL0vp3F/Cs415M9HO69V8I4Amt+TtR qYuzX+DS9M5mHIdfCo6jE4YrndJXp+P9nXrSVT4kHOrFWhPfyxoHR9eDjka0hCLzOj6I UukvTYFVBzUlHeRhgFvk8+8K3fVB9DAL2EVxxuBCrYXujLG3h/jSJpth6/wpgxAx90ja b4Wio/3YEaZDE5RBJ0iIlLzPWjuY7TMgpeJztBDZunQAaLeCwIJRP+mcZOW49LJh5a3k ThvANVOt10nIV+rEV8EReXEkhC/ONaPStbyVorFDeLJ9CSaCwt7ba4I9dJyIMIFJoLPS XlPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.net header.s=badeba3b8450 header.b=jJ8agmZR; 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=fail (p=NONE sp=NONE dis=NONE) header.from=gmx.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gv38si8434473ejc.512.2022.02.22.01.31.13; Tue, 22 Feb 2022 01:31:36 -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=@gmx.net header.s=badeba3b8450 header.b=jJ8agmZR; 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=fail (p=NONE sp=NONE dis=NONE) header.from=gmx.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229891AbiBVIBm (ORCPT + 99 others); Tue, 22 Feb 2022 03:01:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40398 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229437AbiBVIBj (ORCPT ); Tue, 22 Feb 2022 03:01:39 -0500 Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7DD4B148921; Tue, 22 Feb 2022 00:01:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1645516865; bh=Wbkwg6IDeSigfLVXP44w+U6JsS8t374MsL2Uv1lERNM=; h=X-UI-Sender-Class:Date:Subject:To:Cc:References:From:In-Reply-To; b=jJ8agmZRWaSWMbzTiNL8UEB9YSkBvS0meQFiTDtdClaMh1jRW7CSQxXwv5IanTDOT FRpKcavULXTiThiqxwIwyCfB7RRDiIgKUol7byb71+tJat6s8xwCRDKrKoXouXovdP Eh8KLVN1f32FsjtzpXedVLeTuN4Q+FfHHGSFsyZ8= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [192.168.20.60] ([92.116.171.113]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1M8QWG-1nI0GG3dtw-004Qsi; Tue, 22 Feb 2022 09:01:04 +0100 Message-ID: Date: Tue, 22 Feb 2022 09:01:02 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: [PATCH] video: fbdev: via: check the return value of kstrdup() Content-Language: en-US To: xkernel.wang@foxmail.com, FlorianSchandinat@gmx.de Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org References: From: Helge Deller In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:wJCFas3iTYDKRy/G4Q+YVsZlHbHu1InHntEr+HGd7csopCqt0gk Het9BIY3anRiLBr624c2IjMYYMJUZjywh4jthMas2Q5s9EzZrm0uPIK2/Sp4E726khTTnCa eFCCrIIx+PBTlYHRg7ZQHQL9MMDXukUq6XPQkTyiP1xIYMfIkSZIyKsrzM+wGS0GIurVap1 S3Pxl3XB6t4hE8/KJLZog== X-UI-Out-Filterresults: notjunk:1;V03:K0:ZEU8riefV3U=:fv8lZBcdcNQE++XqHrpoeK asv+D/k7hSJ6Yxz9If35D9hoWXtsF5LOd+Lap02rV+c4i9owlERKYMdR1dAU+uqyIg1Lf+R15 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DKIM_SIGNED, DKIM_VALID,FREEMAIL_FROM,NICE_REPLY_A,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham 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 On 2/21/22 11:37, xkernel.wang@foxmail.com wrote: > 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 applied to fbdev for-next tree. Thanks! Helge > --- > 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/vi= a/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=3D", 12)) { > viafb_mode1 =3D kstrdup(this_opt + 12, GFP_KERNEL); > + if (!viafb_mode1) > + return -ENOMEM; > } else if (!strncmp(this_opt, "viafb_mode=3D", 11)) { > viafb_mode =3D kstrdup(this_opt + 11, GFP_KERNEL); > + if (!viafb_mode) > + return -ENOMEM; > } else if (!strncmp(this_opt, "viafb_bpp1=3D", 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=3D", 17)) { > viafb_active_dev =3D kstrdup(this_opt + 17, GFP_KERNEL); > + if (!viafb_active_dev) > + return -ENOMEM; > } else if (!strncmp(this_opt, > "viafb_display_hardware_layout=3D", 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=3D", 15)) { > viafb_lcd_port =3D kstrdup(this_opt + 15, GFP_KERNEL); > + if (!viafb_lcd_port) > + return -ENOMEM; > } else if (!strncmp(this_opt, "viafb_dvi_port=3D", 15)) { > viafb_dvi_port =3D kstrdup(this_opt + 15, GFP_KERNEL); > + if (!viafb_dvi_port) > + return -ENOMEM; > } > } > return 0;