Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp3999629ybn; Fri, 27 Sep 2019 14:46:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqwpz5Ph7OjfgBfgGSfYaLx1Fk0bgzBxypjBoJmaNBdQNvQhCOvNpP05sgJF1YkqHmpnv/Mk X-Received: by 2002:a50:e616:: with SMTP id y22mr6970157edm.253.1569620766575; Fri, 27 Sep 2019 14:46:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569620766; cv=none; d=google.com; s=arc-20160816; b=zM69GSmHT7GyZBXKRUGkeglN/5ljCsij91iyXf1fyIfXQzJ+Id6hDFskeYsn3RwWVE 3oRViTMUentlsAKyjsXLM7ewT5/b1sZaOiIubHK+mIIsgLzWOWiK1CY4zGAMDaoRIJ6K b6pPqV5jAD84lYeBwfjyj/JgVYC32RknK2u0k+fLq+9absq8w/e2WlejQKpgGDHgsob6 k9Z8A35Hzk4pnI3l5D+nAlHS1n5CI89D522rmXyljEdEKHXfUzGBIEuAtp8LMR01bCXF 0wO7JrpHizVVsWUoF892op2vJKjfRhRULzEROWroTBVeTPo1sctsu6e9PoZ9mZCO1u/I LVDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=uQvH5eP9xpiy0f1cPY42CaQQPMr87X6kYcWUTyFt77M=; b=zimGHyb+YxdWQOCges0ES7qEpo4raghdnSWlbr5KbcVtiFRZxlqc/O3NlrDDENRUaI MrvnsgRrXoFfS/SmMQvTBTRE3hguIya1NhzQ3jCTtg7LarUOiPcPa32DrukQ4FVM9+e8 TANhYftsQnAvey1YT0ArBeViP7CWp78EQv6Ey9IpI4XlL8DvkuHpvLi6xsFaXfZS7cJs mz2dLcdmVa89dMMAZXAxgasivEm1jZ+Ws1KljH55rayRNoSMH5zSWCRLWozRsqaKjN45 B/Ch67UfdREfwK/d1Xc0VcJotrOFOG2LIoWcAyg9y1vzPFb3KtuNMBhy4tgRhrg4Qrkr jVvQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b42si2425171edb.11.2019.09.27.14.45.42; Fri, 27 Sep 2019 14:46:06 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728415AbfI0Vox (ORCPT + 99 others); Fri, 27 Sep 2019 17:44:53 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:56579 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728395AbfI0Vox (ORCPT ); Fri, 27 Sep 2019 17:44:53 -0400 Received: from mail-pf1-f197.google.com ([209.85.210.197]) by youngberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1iDy2l-0004ko-Sh for linux-kernel@vger.kernel.org; Fri, 27 Sep 2019 21:44:52 +0000 Received: by mail-pf1-f197.google.com with SMTP id o73so2833246pfg.5 for ; Fri, 27 Sep 2019 14:44:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=uQvH5eP9xpiy0f1cPY42CaQQPMr87X6kYcWUTyFt77M=; b=E3RGK1OqGQNpjzAaawvNYb1mjK7w4F4jnJIskiNznci07QbKKBg6eyhHrleOvbUGO7 XcEiSAcnV5VNAjDDYKxjEKSlkCKh6tRVNT8td2xZQVCqGGpEidpdYHjGiPdbpO5t6FpS PqC6OegD39i/oQLFZjlPh390sih2IVTk3/3wjVKjePCODBfvI+/t27g0tm2cjjtUSIpe vx8jippDvQCOSlygK1l1RLunsPqNgMuX8lVMBBzWZi/DTXgvxLKHvCJrUMG5yFBBZ6tf 79WSFggDErdrLEi1Ywz8gJqzExLcf4Q/NiIMr+DWH2n8vxXaD3VuHkjTmI2aqxkgiEH+ pRTw== X-Gm-Message-State: APjAAAWGH07+P0mzSzHwnRA5nYmLD/2M8Q8Gx9TbwLurZV28dvuY81uJ 6NJ75JyA5ievT5FqdRHTHsxjk8t5egXqTamPzYBH1w0iCEWpESDU0EfTDlmzaUDvPs6COICpd+h 18C8WX+BuHAOgtg57mVBbvpPEfofIB3Nwnrflmg9mFw== X-Received: by 2002:a62:2ad6:: with SMTP id q205mr6844805pfq.46.1569620689696; Fri, 27 Sep 2019 14:44:49 -0700 (PDT) X-Received: by 2002:a62:2ad6:: with SMTP id q205mr6844794pfq.46.1569620689563; Fri, 27 Sep 2019 14:44:49 -0700 (PDT) Received: from localhost.localdomain (c-71-63-171-240.hsd1.or.comcast.net. [71.63.171.240]) by smtp.gmail.com with ESMTPSA id p66sm7150579pfg.127.2019.09.27.14.44.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Sep 2019 14:44:48 -0700 (PDT) From: Connor Kuehl To: Larry.Finger@lwfinger.net, gregkh@linuxfoundation.org, devel@driverdev.osuosl.org Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH] staging: rtl8188eu: fix null dereference when kzalloc fails Date: Fri, 27 Sep 2019 14:44:15 -0700 Message-Id: <20190927214415.899-1-connor.kuehl@canonical.com> X-Mailer: git-send-email 2.17.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If kzalloc() returns NULL, the error path doesn't stop the flow of control from entering rtw_hal_read_chip_version() which dereferences the null pointer. Fix this by adding a 'goto' to the error path to more gracefully handle the issue and avoid proceeding with initialization steps that we're no longer prepared to handle. Also update the debug message to be more consistent with the other debug messages in this function. Addresses-Coverity: ("Dereference after null check") Signed-off-by: Connor Kuehl --- drivers/staging/rtl8188eu/os_dep/usb_intf.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8188eu/os_dep/usb_intf.c b/drivers/staging/rtl8188eu/os_dep/usb_intf.c index 664d93a7f90d..4fac9dca798e 100644 --- a/drivers/staging/rtl8188eu/os_dep/usb_intf.c +++ b/drivers/staging/rtl8188eu/os_dep/usb_intf.c @@ -348,8 +348,10 @@ static struct adapter *rtw_usb_if1_init(struct dvobj_priv *dvobj, } padapter->HalData = kzalloc(sizeof(struct hal_data_8188e), GFP_KERNEL); - if (!padapter->HalData) - DBG_88E("cant not alloc memory for HAL DATA\n"); + if (!padapter->HalData) { + DBG_88E("Failed to allocate memory for HAL data\n"); + goto free_adapter; + } /* step read_chip_version */ rtw_hal_read_chip_version(padapter); -- 2.17.1