Received: by 2002:a05:6512:2355:0:0:0:0 with SMTP id p21csp202626lfu; Wed, 30 Mar 2022 20:46:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxGf99HXKixU9z7K0w3/Z8NIJpWaFvibKfxELgAsVKyBBe8cM5KikgjCe0Ta/wa/7W1LSrq X-Received: by 2002:a05:6a00:810:b0:4fa:e869:f4b5 with SMTP id m16-20020a056a00081000b004fae869f4b5mr3220002pfk.54.1648698385637; Wed, 30 Mar 2022 20:46:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648698385; cv=none; d=google.com; s=arc-20160816; b=VmOeXMhzIkE3St9p2PJO/toZlK3Wn2POc6lAeZje7zYNM1fq7WqF0nn/FRaEuR7dT6 ycjWZPFJsuvbXTHgSUn8zMWEEKCCehV4M9C4fjIgzrc9H7Fl1KBePlngY7Y+RhdeKMrD plbLBaBq6aiIZzRxUPo7lwXByoGxkTP7vWcwK9y0iFDJUgdx6Fh8HEJ557rfxBqw9jrS 8iHf1703RaltEqEltlovlZjIoiWdoxlAn4bP5k3JUmEbMR/4J99yQAtJ86PaHTN6JOue XZsCG8d7b3ucLnm5yWlhOu8nHxKIdtaxfKZQpNHb2DRoEuDwfe1r3yDyCPd0YDUe7HIA lBkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=qSTrUL6WlyOgAbYd80glH9hQCFNO5qIECH8QC7MsZz0=; b=JTJMzPWMy0le+gL9BQl57FxuIpdMK1d3vs2PJnNcRDnoaS1F24h1aHms9EyaKvtco3 /9nhEwGUhUxnK4sDaZ3MYUwYE3eADh59kh0MdXCnC1d8al30B/mFh81N8+MkJSsduOCS rtVVs9746hEjeK47mOVzhrOfMePzGFTvxbMmsjADRI0UfLJdeleY5+j8ZqaEDVCDVgw5 mP9o2PCjdJnMVkSstIJ3RkYu625A+M5458vxw6w7nui/EBXnp+YIxiqvAscjUXTsexyO cfMB2evkJ7pk6wu4YD8WOt0ba4YYtAwmaHbRrugYVzpAuj5j27w7tJYCD4lLZSkchx6J qfVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=google header.b=BzP5Vs5p; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id w23-20020a17090a029700b001bd14e030a2si1890174pja.122.2022.03.30.20.46.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Mar 2022 20:46:25 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=google header.b=BzP5Vs5p; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 05D9822281; Wed, 30 Mar 2022 20:03:14 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237912AbiC2Ofr (ORCPT + 99 others); Tue, 29 Mar 2022 10:35:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39888 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238009AbiC2Oed (ORCPT ); Tue, 29 Mar 2022 10:34:33 -0400 Received: from mail-io1-xd35.google.com (mail-io1-xd35.google.com [IPv6:2607:f8b0:4864:20::d35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0AAE01C935 for ; Tue, 29 Mar 2022 07:32:50 -0700 (PDT) Received: by mail-io1-xd35.google.com with SMTP id p21so7217622ioj.4 for ; Tue, 29 Mar 2022 07:32:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=qSTrUL6WlyOgAbYd80glH9hQCFNO5qIECH8QC7MsZz0=; b=BzP5Vs5piewGOcMGK+PbvKkzV47OGA/ob4vuN1NMspDx8Y39MtQLR3PC5d1JDBTYoB GaboRGeOd2ntywJe32ct9vlJTtMx9t3x0SXCZDIUElARJwvkRP17EtlgC26exdZVuSiR jk0U7rd0yJPJP+H8mPYNbV6HpQo6OhNp1+aDc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=qSTrUL6WlyOgAbYd80glH9hQCFNO5qIECH8QC7MsZz0=; b=wtim3NSF5DpMRFjs6LgYZTSHlcToVmQEPQ0RvtbDSCh3Yivr5GpQ7JPzhB5s2MnY2f dFTB/J7atiz0N0RkUvv/i52W9DwqNtUOKmy+NmBR1GfFdRNPwV79bW5H0rcOOdJFsoTs dMq3lttVfFUDuvujoXmttCTFvza2YRqXD10qAZ7RA6Xmo+x89QKJV5PC6GWUI3D/9oi2 YP23nbH7cMvpXyTo4C88txe0XcJ6vQkdyhXhivR4FVLV0abli9tzD6GXqWSTd6mTD+41 U24BD4VWWDtE2wziRrMnTrFWPcZWl5QZ0YK//Cvy9AXgLDX/L0tI4kzLecP4I0Ktad+c zYgQ== X-Gm-Message-State: AOAM533aSNxnfdEmHspc6urdEXmH5EbyEmnFF+l5VU1rln+IExsqzc/6 cazIaDWOwoICMBPlPtHb/3iFMw== X-Received: by 2002:a02:604f:0:b0:30f:e6f1:3883 with SMTP id d15-20020a02604f000000b0030fe6f13883mr16742779jaf.266.1648564369340; Tue, 29 Mar 2022 07:32:49 -0700 (PDT) Received: from [192.168.1.128] ([71.205.29.0]) by smtp.gmail.com with ESMTPSA id n4-20020a92d9c4000000b002c886034defsm6932289ilq.62.2022.03.29.07.32.48 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 29 Mar 2022 07:32:48 -0700 (PDT) Subject: Re: [PATCH] usb: gadget: udc: add NULL pointer check To: cgel.zte@gmail.com, balbi@kernel.org Cc: gregkh@linuxfoundation.org, peter.chen@kernel.or, christophe.jaillet@wanadoo.fr, lv.ruyi@zte.com.cn, johan@kernel.org, jakobkoschel@gmail.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Zeal Robot , Shuah Khan References: <20220329055407.2375626-1-lv.ruyi@zte.com.cn> From: Shuah Khan Message-ID: Date: Tue, 29 Mar 2022 08:32:47 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: <20220329055407.2375626-1-lv.ruyi@zte.com.cn> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,RDNS_NONE,SPF_HELO_NONE, 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 On 3/28/22 11:54 PM, cgel.zte@gmail.com wrote: > 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. > Please add information on how this problem was found, including the tool used and warn message. > 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; > + } Looks good to me. > udc->status_req->req.dma = DMA_ADDR_INVALID; > > udc->resume_state = USB_STATE_NOTATTACHED; > With that change to the commit log Reviewed-by: Shuah Khan thanks, -- Shuah