Message ID | 20221117071825.3942-1-eli.billauer@gmail.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp258461wrr; Wed, 16 Nov 2022 23:24:43 -0800 (PST) X-Google-Smtp-Source: AA0mqf5FbZOBA6umMUTZPEcpDNKA9ijmNyUPzZHduEI1kLVzy/MN0x86ft2wjqsHVqUkBaN/s9f5 X-Received: by 2002:a63:c46:0:b0:476:ed2a:6228 with SMTP id 6-20020a630c46000000b00476ed2a6228mr1049140pgm.137.1668669883592; Wed, 16 Nov 2022 23:24:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668669883; cv=none; d=google.com; s=arc-20160816; b=wFeGCKKVg5ASa4ZfcwwEwtEuO8W5WZp/T7AanRingGEaMrga+i6yXMDDjpEQFqYItO KTDi9DyM9HYXir1qDbuHMUUG4zld5Rc5Gu2bisvuOEN0kPVqMYHf3NYhFwtjc6CLjduP oA+1KEoVlhyElq0wXtAEyJMYAQzFCCdSZgFCN3NpqqNx2XviAGk2c0ysIWYDAAnaPt3f iPAfy2kifPh0IS6OIpuMO3AGFC21m7AQNysanvlMIho5SErLYU9zroqBNbzcdnkxJr9L anIKsQCxx0wGSvzIhzZry8oAVLpk6ztvWGSvWZ0Zg+63ATFr5pxPvVjXsmwXgrmykX8F WiAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from :dkim-signature; bh=T81/5fLCvQ7zJ3Q+OGaVNq/xGeY/shWwLqml1r4UttA=; b=FnR/fjmk9r2IHsdD3ztRUfwkn296Jo+7d4e863Z/78jrmQznKq88kZ4+N1DSw0i49b g8sucGuKQiXYpK070Ib44VmEjaRBdBBWRxkmEEijZoN5I9g86wUzhw0zw5MNU/npM14X psKKMzUHCDHSoGIIk816jqX0QK5G1/HlbQaZnXlxCFbSxl18CKoM5sWNSEPS4b8DzDA4 yh/qvTgVGx59k25QHkyavsGtU7tvjoCikcM6X1KYsaDpqAcyDloqQULIahNNnrfEzuUJ B0vXPlJB3Xbqdrv3im4uct8jWL3H9d7/1T3Ly6LCGDO7bKfeOGjTzL9zyYrSLeLVeqGf Cweg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=g+JlJalF; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k3-20020a63f003000000b004606d9040b8si326267pgh.387.2022.11.16.23.24.30; Wed, 16 Nov 2022 23:24:43 -0800 (PST) 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=g+JlJalF; 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 S239173AbiKQHTG (ORCPT <rfc822;just.gull.subs@gmail.com> + 99 others); Thu, 17 Nov 2022 02:19:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234503AbiKQHTD (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 17 Nov 2022 02:19:03 -0500 Received: from mail-ej1-x62d.google.com (mail-ej1-x62d.google.com [IPv6:2a00:1450:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0FC2328E20; Wed, 16 Nov 2022 23:19:01 -0800 (PST) Received: by mail-ej1-x62d.google.com with SMTP id f18so2891832ejz.5; Wed, 16 Nov 2022 23:19:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=T81/5fLCvQ7zJ3Q+OGaVNq/xGeY/shWwLqml1r4UttA=; b=g+JlJalFyfkuRhZgHgB1WiVyFtcCzlXAKGT0Hhz5ioaV/axZtkgdxBoxLeYRd3lyCE BZDOTfUZMDH6gzoIvIwW5uh3iXT5Hup7pn+QZTP4CUguTmVNdDS2KLIHJhQq/Ely5dMq fu3kOGVPmoHdXuHDe4Usm8J9Ojy3Ol8Rt84kJs/H2JznXL+t041Zza5RrG5wdkxaiwVu o6XgaoTbkakzydz2x8MFwLg/AKw1Gu6xnmhBMz0MScMUXdtq4SPsmEZL7Z6A3yplx8xK 9zcLXugEAYjK3m3Gj35G+YANGL4yE5QJ3INj/KHv20ckVXEFI7kDi6fpMOOvnKoZ6Qrd b4jw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=T81/5fLCvQ7zJ3Q+OGaVNq/xGeY/shWwLqml1r4UttA=; b=ms2JawHDsyZ5YTPQxhfTCRrigOXlA2KnGSjd+q4l4IywOMTuF2suapZH+4NiU/rNUD 0axvx6+aIQ/zyxLeq3w1zxQQhZ0mLk1y4XhnRlueQFGMs0TFM0/pWIlazEQc3DxF/jXw asw/57LbdxJ4HgihsV9SsPILdgTcZahU2y88heOEArGsopynLkZi+sNndApDgnQaemwv LH0BujIsx7kpfY5iyEWPNChACFp47XzTbFtlcyx4R+1xHFIAmdIQmlQsEH5h9lxXRDRO oqaCxktyJlOfLvRi4RrVj39yryRwr0gXPp245cr3LolmW9BxFKuyvQSN74Tx/uzIq8lm Erng== X-Gm-Message-State: ANoB5plKd9vacrjc35q1cRr8gw81jGD4+bnpGmE7NltsPA3SbR0U6ulw ogGaiRd2EdKHmt19bLAwosI= X-Received: by 2002:a17:906:229a:b0:78d:d762:5457 with SMTP id p26-20020a170906229a00b0078dd7625457mr1158533eja.67.1668669539494; Wed, 16 Nov 2022 23:18:59 -0800 (PST) Received: from localhost (89-138-235-186.bb.netvision.net.il. [89.138.235.186]) by smtp.gmail.com with ESMTPSA id en20-20020a056402529400b00461bb7e7ef1sm154207edb.30.2022.11.16.23.18.58 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 16 Nov 2022 23:18:58 -0800 (PST) From: Eli Billauer <eli.billauer@gmail.com> To: gregkh@linuxfoundation.org Cc: arnd@arndb.de, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, imv4bel@gmail.com, stern@rowland.harvard.edu, Eli Billauer <eli.billauer@gmail.com> Subject: [PATCH] char: xillybus: Fix trivial bug with mutex Date: Thu, 17 Nov 2022 09:18:25 +0200 Message-Id: <20221117071825.3942-1-eli.billauer@gmail.com> X-Mailer: git-send-email 2.17.1 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 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749727191948636974?= X-GMAIL-MSGID: =?utf-8?q?1749727191948636974?= |
Series |
char: xillybus: Fix trivial bug with mutex
|
|
Commit Message
Eli Billauer
Nov. 17, 2022, 7:18 a.m. UTC
@unit_mutex protects @unit from being freed, so obviously it should be
released after @unit is used, and not before.
This is a follow-up to commit 282a4b71816b ("char: xillybus: Prevent
use-after-free due to race condition") which ensures, among others, the
protection of @private_data after @unit_mutex has been released.
Reported-by: Hyunwoo Kim <imv4bel@gmail.com>
Signed-off-by: Eli Billauer <eli.billauer@gmail.com>
---
drivers/char/xillybus/xillybus_class.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/char/xillybus/xillybus_class.c b/drivers/char/xillybus/xillybus_class.c index 0f238648dcfe..e9a288e61c15 100644 --- a/drivers/char/xillybus/xillybus_class.c +++ b/drivers/char/xillybus/xillybus_class.c @@ -227,14 +227,15 @@ int xillybus_find_inode(struct inode *inode, break; } - mutex_unlock(&unit_mutex); - - if (!unit) + if (!unit) { + mutex_unlock(&unit_mutex); return -ENODEV; + } *private_data = unit->private_data; *index = minor - unit->lowest_minor; + mutex_unlock(&unit_mutex); return 0; } EXPORT_SYMBOL(xillybus_find_inode);