Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp3922400pxb; Mon, 4 Oct 2021 12:43:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzO4A7EJH7+TR1ZansH4LL/8hU97hvqoalDinUJtu+qZPL59vg+QYBLk/wAKQTm5hIj3fri X-Received: by 2002:a17:906:4c8c:: with SMTP id q12mr19322623eju.254.1633376598578; Mon, 04 Oct 2021 12:43:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633376598; cv=none; d=google.com; s=arc-20160816; b=gQndqbt2pAxVPeiYixNAmBWBwB0qVhRX/HuzcwHTToFviVKFMgiZjsToYbI/iWEEcg ldau0iPz7ojDQzkY1dqpU9uJHHNx9A8oQE+iIeoLpE62bfeQHVVCtpNIuzxWI3WhgFLa ZYitiTyWw9FECeOiZkUGgzk8ZsiK6Q3uQDE7UJ+PmTZMwbwe26mI7mQmnTi5YJG70J6t fTBXp4yqgfYpvDC/CgmQPZJYJaVKGn47nda5k6JYGW4pKz/Vma8AW3SqA7IC/NnpQZgo KusvZgfnHwb7QnpAs8f6RIGC9Y0CscESESezcanA6ujf+5/lbmMW+XUYmkPuKwTmm3nv 92AQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Yy4C+6aV4jiTdHc84STurceKi3a7R1TGAq8njAU/vGc=; b=IuUg8x8+4jpR1gii9WJVSG/ofbTG+rI9reVpVdml0qCqZh1iTAEb28AFlhwhIKkUjJ EJ0ZqfAyqnqVd31qQdJxYx7JdLo29SbzZmci39FeNHHmOOipsWPkSrKCzN6yQ9KAPaEA o1k0gfK/GOrUHUW9iD/xKZGQhqDa38gQMP/A8smb/FN1ZTTg7DDm/l+exebv1NY/9D/O jPMtcsuE4S7ghmhG7dm8EfMli70m/kF40LrFkpBpJP4bY9emHSujX9n9BsVMHG3z1wlN mdK5xNnQo5r6jt+GvR8xS7ntK7C5W+mFIEEZxxZHpxdX4FQH8QApMulqN5KSPWqPsU46 0fEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=sEalYlY1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f29si6705961edj.578.2021.10.04.12.42.54; Mon, 04 Oct 2021 12:43:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=sEalYlY1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234686AbhJDNDE (ORCPT + 99 others); Mon, 4 Oct 2021 09:03:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:59970 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234270AbhJDNBn (ORCPT ); Mon, 4 Oct 2021 09:01:43 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5843D61A05; Mon, 4 Oct 2021 12:58:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1633352319; bh=oW7tEkdYVS0Qd9dZHnKmmTbzN3l+ICLyNp33Z63vQKM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sEalYlY17tjmIiY2oe0EUy7ObWL2wnitd9PIoejkWLKPqdPerkz6BOkcSCBFU9YMv MHGlQEryoAZ1f80FCB+uqzAtf1MrtH8Nu+70DZZJytYMvZSFnS7e1FLmZjMIBipnXe 5VEFm7oeU4mOYI2CM7DU4HJpFB+VRo4IDclc6w7M= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Johan Hovold , "David S. Miller" Subject: [PATCH 4.14 16/75] net: hso: fix muxed tty registration Date: Mon, 4 Oct 2021 14:51:51 +0200 Message-Id: <20211004125032.073955157@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211004125031.530773667@linuxfoundation.org> References: <20211004125031.530773667@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Johan Hovold commit e8f69b16ee776da88589b5271e3f46020efc8f6c upstream. If resource allocation and registration fail for a muxed tty device (e.g. if there are no more minor numbers) the driver should not try to deregister the never-registered (or already-deregistered) tty. Fix up the error handling to avoid dereferencing a NULL pointer when attempting to remove the character device. Fixes: 72dc1c096c70 ("HSO: add option hso driver") Cc: stable@vger.kernel.org # 2.6.27 Signed-off-by: Johan Hovold Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/usb/hso.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) --- a/drivers/net/usb/hso.c +++ b/drivers/net/usb/hso.c @@ -2713,14 +2713,14 @@ struct hso_device *hso_create_mux_serial serial = kzalloc(sizeof(*serial), GFP_KERNEL); if (!serial) - goto exit; + goto err_free_dev; hso_dev->port_data.dev_serial = serial; serial->parent = hso_dev; if (hso_serial_common_create (serial, 1, CTRL_URB_RX_SIZE, CTRL_URB_TX_SIZE)) - goto exit; + goto err_free_serial; serial->tx_data_length--; serial->write_data = hso_mux_serial_write_data; @@ -2736,11 +2736,9 @@ struct hso_device *hso_create_mux_serial /* done, return it */ return hso_dev; -exit: - if (serial) { - tty_unregister_device(tty_drv, serial->minor); - kfree(serial); - } +err_free_serial: + kfree(serial); +err_free_dev: kfree(hso_dev); return NULL;