Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp190698pxb; Tue, 29 Mar 2022 02:25:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxpDBua2xGnqdrSf2L8DGs/DWhAxRqohQIiDiM5cyJiiFkahjwcoaiO7+gmD6xCwswBpXvX X-Received: by 2002:aa7:c946:0:b0:416:226f:f8a6 with SMTP id h6-20020aa7c946000000b00416226ff8a6mr3316736edt.360.1648545910192; Tue, 29 Mar 2022 02:25:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648545910; cv=none; d=google.com; s=arc-20160816; b=wBV3IjLP/BCf0seF6Iu8+pXRD4FwxsHbN05LLfeOqf4iSAWBrOvAWVcybui18d2CvX 40xbLXiq+GL9CArDGqYd/uLHbeOJoObO+thXdVTBaL2IGprxE734NlCHGpK6d+AHGiNb Q/hFlSqCKsQcLEEoEdE6fmSL9C/AfkTrkfxodSIe+NEp2G+HSCQRDn7dXh9ot7eUB7Ip nhqvDlEiW/w8gdJrdFv4CAPVtUz7YVXL8RIIaZqRTCB5SIL/i4iB13uqz2FRee3GiO7B qRdZABRzWtbbsaLwR4s0e5oBXt7Yi6iZQBDUrUhhg6o0Gd9b35kduiKyveGe77nAejq1 FR6A== 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:dkim-signature; bh=Pv+YK+YGh5jKY9olKETrPHwQ2n/4aGK/xdNlhbRhxZE=; b=OJ4C1pwULPv1RzPO+E3yKzMYrPqkvho99J5OF/71MJrQI0arxbz8QlQU/fXlUe5MAX VsyaU/EL9m5g8Kmv2Z8b1mNzt/PZRoNYvLPsdzhYwll2nCjFHG/OptzOJbsvdJeRdPGV MkjnYSjJX7FXRLpUR3SWpYpbFYCTsoX46TNzRT/wVz97K5M/y92YlwWyPWEtnd/VXwER PINmKPf+QVEkz5fp7QHW7wCyjqAU8OajNSO0FCisqkdWrKIrdZiux87a95BVetffBA/m U5Q1yg1UCEfbPmN1NG/vBHQX0BlUIGxx0krADPf8bisrtnzQzVF/GBOZRr+n9YAcA9aC 8woQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=bzfdyo0u; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n10-20020a1709061d0a00b006dfb9006429si17316721ejh.936.2022.03.29.02.24.40; Tue, 29 Mar 2022 02:25:10 -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; dkim=pass header.i=@gmail.com header.s=20210112 header.b=bzfdyo0u; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232747AbiC2Fz5 (ORCPT + 99 others); Tue, 29 Mar 2022 01:55:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55168 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231578AbiC2Fz4 (ORCPT ); Tue, 29 Mar 2022 01:55:56 -0400 Received: from mail-qk1-x731.google.com (mail-qk1-x731.google.com [IPv6:2607:f8b0:4864:20::731]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E7436117C90; Mon, 28 Mar 2022 22:54:14 -0700 (PDT) Received: by mail-qk1-x731.google.com with SMTP id b189so13272997qkf.11; Mon, 28 Mar 2022 22:54:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Pv+YK+YGh5jKY9olKETrPHwQ2n/4aGK/xdNlhbRhxZE=; b=bzfdyo0uWDEELn9OY8t+TxbY1Ftpv5siDPYc9FfEkJVioVH+JcBmi4NXkU3ExK4txJ V4wcKhhNtNJj/mSRct/VeLhvQ/xVpG+cstkFDYUCPLDX7Ancm8YxbX7cVKvXBS1Scrqf RqYBvlZVwjxP+E3A14MYIgKwNfi4PO8Esj9PM4uH1PrSiDct7BJkTyqtYUG/ooWacNOf /0f7m0CtjQTpx+bpWNEX5nmGTzq26HAwaRLvizDU0bdcKh6MawRNNR3/SvZBeuIV2Wgn P/+rF+neDixlfmZ+g0aODbF+n6mAUD7WYaIwmK5bTgIxe4vX4+x2yvvfjeCUTnnGBNN8 UemQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Pv+YK+YGh5jKY9olKETrPHwQ2n/4aGK/xdNlhbRhxZE=; b=itCTQZtf7yzmgEjeN5fn83ck4V1MSTiY391q22MMm4suwjmXYHWK0nfQFqNfeRdHA1 2M0uL8zvoX3thCrUQeV4RW79S49+8Zo9LitKm5lRVG0YhbY4WmiNk+Jgyifti30aMoUr 7OVxdR4t0texIQpHQXnA4IM+6qVLFX42lGOlh5X6KE8bim+91jpsPHYwZP2sGsg46eC4 aVyRFmASc/nElrKsb/8SGxit8EkacNHY8NzNz8Byx4wM4E6sc/8QsL7SmyV+Ateu2YJW BcZlug754WDnZgy7kqFijHmrSlG4xv5RibGBxp2FzqfJIRBqvwWsJiYjEjjlJs430xM8 Mfag== X-Gm-Message-State: AOAM533NqyCX+zyaUOdSQzbi0HXdTdZltoO2JCZFZAqL9pw4vHHig/Dk /zxwiWlKPuOrJohgT8sj7SM= X-Received: by 2002:ae9:f448:0:b0:67e:1929:1782 with SMTP id z8-20020ae9f448000000b0067e19291782mr19142197qkl.578.1648533254133; Mon, 28 Mar 2022 22:54:14 -0700 (PDT) Received: from localhost.localdomain ([193.203.214.57]) by smtp.gmail.com with ESMTPSA id m14-20020a05622a054e00b002e2072cffe6sm13749111qtx.5.2022.03.28.22.54.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Mar 2022 22:54:13 -0700 (PDT) From: cgel.zte@gmail.com X-Google-Original-From: lv.ruyi@zte.com.cn To: balbi@kernel.org Cc: gregkh@linuxfoundation.org, peter.chen@kernel.or, christophe.jaillet@wanadoo.fr, 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 Subject: [PATCH] usb: gadget: udc: add NULL pointer check Date: Tue, 29 Mar 2022 05:54:07 +0000 Message-Id: <20220329055407.2375626-1-lv.ruyi@zte.com.cn> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,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 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; + } udc->status_req->req.dma = DMA_ADDR_INVALID; udc->resume_state = USB_STATE_NOTATTACHED; -- 2.25.1