Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp4207727pxp; Tue, 15 Mar 2022 15:18:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwmycU948vFXyH/Ts83+i0zrPv32NuXjw9LTyZavwKilx8C25g/Pnnd9yIaRqBNeVfaEF9b X-Received: by 2002:a17:907:96a0:b0:6db:a7d5:166a with SMTP id hd32-20020a17090796a000b006dba7d5166amr18329316ejc.725.1647382683425; Tue, 15 Mar 2022 15:18:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647382683; cv=none; d=google.com; s=arc-20160816; b=thnCG55qyjKW4CFTEd13qDqrpGAoYJIFVKHg15gFvkhyuPHsRH21y2fpU4oMuRActo 9q7kNqhvPvQSRoszR8lWZdDf/Fa0IAsuy+p38YR+bCqA/u3dwvcvYhxH9X8aaFm+9eDN LwAR9P+gBd/C6nMiCRfWLc25/fPrrWH0Tq+0ae/PE/cZ1SHhouRm/9azBC5+UIU0goJx TCLngyQMnOQliLJqe2KNmPYtAxioaDFsoTB7ttkJF8aZNPun3eHtooX+TlBqIem1ng1k FRXSmBOh9rmKQ57XtbpGReuIEXhQy/H1aNKdNOjPZ3j+kG9BQzsKN0UIAduFuhP2SO10 vCfA== 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=wovb6kZT2Sne2tbxUxcchS5UK7kD/TEn0ztb8HjtObQ=; b=WGs7HVquB3uv7RpqtOFzCI9ovUendFsCSQmKcixTeKLaiiMbanyQMKcyB5yC1F95Qr 4jlSFQ6dsJLcVuXDfP4HhMheEPVwkXdn3YzKZACMwT6JnRa9mX31lwc/GBLQ5XSh/GKG G5pd/hv+ikJp3bot5yJaoFlBsbyY8TLRYW9gylBRXvcqarklr4/eHlxSXla8QqqTOG6u sqs06IQliTYgir+8XfretOHavGyvKPH1j2ZHdYRF6A/GRgslW/ezr8zu1wV+FTrXZRR+ DoA74IoCMSpZJEEbsaTVod53Rn/tuS4atav3xnMIMb3R4nCP043SoucpDsZAlIkdvzfU oKYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@foxmail.com header.s=s201512 header.b=fMaSrYd9; 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 z2-20020a05640240c200b00417bdbad510si260144edb.382.2022.03.15.15.17.38; Tue, 15 Mar 2022 15:18:03 -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=@foxmail.com header.s=s201512 header.b=fMaSrYd9; 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 S1349408AbiCOOpR (ORCPT + 99 others); Tue, 15 Mar 2022 10:45:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42326 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349425AbiCOOpO (ORCPT ); Tue, 15 Mar 2022 10:45:14 -0400 Received: from out162-62-57-87.mail.qq.com (out162-62-57-87.mail.qq.com [162.62.57.87]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F32C364E1 for ; Tue, 15 Mar 2022 07:43:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1647355433; bh=wovb6kZT2Sne2tbxUxcchS5UK7kD/TEn0ztb8HjtObQ=; h=From:To:Cc:Subject:Date; b=fMaSrYd98a92qYeqSobQ5oDmyXHDa9ke+pGM0pi73PG6fuQSItulnA3ek+4n5lzqN hefDeur3lPjM9NTU4nK1ehjF7ay0ebepUIKF/QBoN7cVHLSFSzTdsz+RUS3zf0t+nw Uie6xnIIGfk2NMgfaauv7dyh/gu6KBLO6Gtyq3hk= Received: from localhost.localdomain ([218.197.153.188]) by newxmesmtplogicsvrsza5.qq.com (NewEsmtp) with SMTP id AA5BCE99; Tue, 15 Mar 2022 22:42:37 +0800 X-QQ-mid: xmsmtpt1647355357tmli9xpaz Message-ID: X-QQ-XMAILINFO: OZZSS56D9fAjLrdrsX39shVro39worYR1UDLSN2cTyEArcFFifoOABgXifLxwX 6JFdXmQ7B/PQCQbi0Z5tftnnOjpmVgZD8RCJnkc0ADg5oiDEqwS4lcakdY7R4gdtg0YUSrlF44FE IEBz08CP03lfcyTGcinz1HXZlHUzXdSi26BEKEVLWCe3PSpcUOPeMWg+HSgXlbSUaHUr6a7OSaPg ty5Wn9GRqRls5YcCMRraDw9jBN1xXZ+N3yrryrhRKq3fJ8og86F3Dc7RZ/bqYxZa3NW/Upvxw608 U6u1DNffgjKSp+sMcyENm7FT+DWY/NPSC86MwjroOuSgb4TnQSDG5qnDemkhXhxeSJOsfOyH/cVh MaQYgU1dYv/akE2ojDUWB2gbCipRN6opdoyQpYBZu52lToH3IOMiH1j1mluS4qdL1zMCyg3wP92S r91pM7JpAAoNdbzF1TUSlTXRB9QL3rkh/hoRdKZGMEWaLFD1RU8sud4YyLmHnpF/NSxJ6l+v/Wru Gf5kDwnbJxtlShFh1Bi/9KfNqd6wSg8ymYH0aFp+Jf9+pOgX25i096QFdpOKy3/wctohsLnrZpL/ eaVP+QGpYTDJrkRWymozTM0pNLnP/TnrRQYwWsXk/eb54mNty/xOhAsy1XqiJX+1m/WBe2E5TNMH bvfFM+gj59CLjM5LlGsHv+SLbQG+zGnuPmM8vWrOX+y+Ym/S9FSAIdJTVITZBeJX84vThfzuCpz7 OecP4pIQypCJwJtqewUwqlTqdueZJr4UYRIMhm00ER+Lm7tVnk6JSgl9xA4Dev/6iPG57sunKNRs 3eIL1EGLVPb+aFHuFOvE+Sovup3Hd7jpJTi8CxLeHo5AiW/8cUZsBrtQYn7Mu+gVY43CpxJgI5T3 ZzrFKCPBJDsgJgFNnaw9u6eo+75KUTXQpvJvMutOE9+SPH7DTdHMIA3oAemwkp0cpQ3UHta8AgPz jmFyPeWMNv7fDu+FwSyVYX2xFw4Qaynv2O9VtkDQU= From: xkernel.wang@foxmail.com To: gregkh@linuxfoundation.org, nsaenz@kernel.org Cc: bcm-kernel-feedback-list@broadcom.com, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org, Xiaoke Wang Subject: [PATCH v2] staging: mmal-vchiq: add a check for the return of vmalloc() Date: Tue, 15 Mar 2022 22:42:07 +0800 X-OQ-MSGID: <20220315144207.623-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,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,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 vmalloc() is a memory allocation API which can return NULL when some internal memory errors happen. So it is better to check the return value of it to catch the error in time. Signed-off-by: Xiaoke Wang --- ChangeLog: v1->v2 jump to the proper location and remove redundant instruction. drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c index 76d3f03..ff4b484 100644 --- a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c @@ -1909,6 +1909,10 @@ int vchiq_mmal_init(struct vchiq_mmal_instance **out_instance) mutex_init(&instance->vchiq_mutex); instance->bulk_scratch = vmalloc(PAGE_SIZE); + if (!instance->bulk_scratch) { + err = -ENOMEM; + goto err_free; + } instance->vchiq_instance = vchiq_instance; mutex_init(&instance->context_map_lock); --