Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1507248pxb; Wed, 30 Mar 2022 05:15:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyAi4ZxPpBNPfRcHgww0o0Srif2SdIv81OycpdE4mBmzSMXCBUwACqdpqnLqojJeDtk+rA9 X-Received: by 2002:a5d:9d84:0:b0:649:d813:4d22 with SMTP id ay4-20020a5d9d84000000b00649d8134d22mr10728699iob.133.1648642529447; Wed, 30 Mar 2022 05:15:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648642529; cv=none; d=google.com; s=arc-20160816; b=kGf3ak9HJ1iKjIx+FuwQSsbXDIFq739WaXJmc+f9PmBnQD0BvvgiYtJT7uMsGA9SLA X/XYSY2ZWUhgXxodz3X5VGBOVmLz+oQytE+DaOwq29ffMuvL23hBUoVgh/F3phNDws0g 2t6d6N7Pr8Y4b2GDlAZLufd/8Gfu9+x5Y0SJel74hh0/TEcv8UOeW7c4s98g9wIkxPHQ haIG3Vcl1p9wy/VQfiHvk/4y7yoicbFone+YY5nOutiQHgevnPDgALdoqUc4OcJ0bRo0 ptLODvv9eW4f7PA2Ko2t+/7BmgjexbRbjl5seXZZfIodaKk+D6dbCZMDpHi1884bTHT4 Z/vw== 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; bh=xKFRGfH1PFvOCRAuglFMGwvarWbPUTVO2kGX4eyw+c0=; b=Y8M65naIKab5ogO1hWq8wAB0PGdeKs1u3bHVZXtV+uehqQYPU33SWDjNDG7XMzq6W8 lr5crsLA2ACQBbDxDAZ5WFPAraddwYHsS9M7ljysuFqVUkiSCN3Fs4me+GpaMKe9taYM 7PUJ2bZwyNB+kvrnDdYMbv02mBwL4n1l4cyOavjBT3nzPsfifCeRVEdupanLHBN5ntx6 yWzH4koIAI79/XmVg9vFK6wd/yHwbmChFZIBylLqndbs7b/3G8D/vrEAqkjS9rlxDamd d339Vavs15L80aMkERc6MNXuK+TxXw2JMXCPXYM4cEYHjsS3QTvvAc8D5g3qzfKArF0X OdtA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a127-20020a021685000000b003214fba2875si16416167jaa.4.2022.03.30.05.14.59; Wed, 30 Mar 2022 05:15:29 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231454AbiC2St2 (ORCPT + 99 others); Tue, 29 Mar 2022 14:49:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58354 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240693AbiC2St1 (ORCPT ); Tue, 29 Mar 2022 14:49:27 -0400 Received: from smtp.smtpout.orange.fr (smtp06.smtpout.orange.fr [80.12.242.128]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4B0051BA476 for ; Tue, 29 Mar 2022 11:47:44 -0700 (PDT) Received: from [192.168.1.18] ([90.126.236.122]) by smtp.orange.fr with ESMTPA id ZGsVnTTcWuCn2ZGsVnMSTo; Tue, 29 Mar 2022 20:47:41 +0200 X-ME-Helo: [192.168.1.18] X-ME-Auth: YWZlNiIxYWMyZDliZWIzOTcwYTEyYzlhMmU3ZiQ1M2U2MzfzZDfyZTMxZTBkMTYyNDBjNDJlZmQ3ZQ== X-ME-Date: Tue, 29 Mar 2022 20:47:41 +0200 X-ME-IP: 90.126.236.122 Message-ID: <63e05f0a-6fb0-c7dc-0c3a-467a5c4e11da@wanadoo.fr> Date: Tue, 29 Mar 2022 20:47:38 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Subject: Re: [PATCH] usb: gadget: udc: add NULL pointer check Content-Language: fr To: cgel.zte@gmail.com, balbi@kernel.org Cc: gregkh@linuxfoundation.org, peter.chen@kernel.org, skhan@linuxfoundation.org, lv.ruyi@zte.com.cn, johan@kernel.org, jakobkoschel@gmail.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Zeal Robot References: <20220329055407.2375626-1-lv.ruyi@zte.com.cn> From: Christophe JAILLET In-Reply-To: <20220329055407.2375626-1-lv.ruyi@zte.com.cn> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE, 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 Le 29/03/2022 à 07:54, cgel.zte@gmail.com a écrit : > From: Lv Ruyi > > kzalloc() is a memory allocation function which can return NULL when some > internal memory errors happen. It is safer to check NULL pointer. > > Reported-by: Zeal Robot > Signed-off-by: Lv Ruyi > --- > drivers/usb/gadget/udc/mv_udc_core.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/drivers/usb/gadget/udc/mv_udc_core.c b/drivers/usb/gadget/udc/mv_udc_core.c > index fdb17d86cd65..f52eb3f2420a 100644 > --- a/drivers/usb/gadget/udc/mv_udc_core.c > +++ b/drivers/usb/gadget/udc/mv_udc_core.c > @@ -2231,6 +2231,10 @@ static int mv_udc_probe(struct platform_device *pdev) > > /* allocate a small amount of memory to get valid address */ > udc->status_req->req.buf = kzalloc(8, GFP_KERNEL); > + if (!udc->status_req->req.buf) { > + retval = -ENOMEM; > + goto err_destroy_dma; > + } Hi, not directly related to this patch, but I wonder if this kzalloc should be freed in the error handling path, and maybe also in the .remove function. It seems to be leaking. CJ > udc->status_req->req.dma = DMA_ADDR_INVALID; > > udc->resume_state = USB_STATE_NOTATTACHED;