Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp472917pxm; Wed, 23 Feb 2022 04:40:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJz+F1rNE4qA4jHXp90qShKyoCYGMbjlauzBqG1ZKmvaV97MEtHEAssgk41lWtSVgt2Hbn6p X-Received: by 2002:a63:950a:0:b0:375:64a3:f98c with SMTP id p10-20020a63950a000000b0037564a3f98cmr1267376pgd.22.1645620031772; Wed, 23 Feb 2022 04:40:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645620031; cv=none; d=google.com; s=arc-20160816; b=cmsfAkPVGZgV2WgbpjAu2/3xN6krjemTB97kJGCTpIkURxkc2R9Y1DXKYVQLU1NC74 08uWx3kTBCLXoJANTF2A8VqB/nN1wTQkJU7jjiCF7qbtmlNXbqOG6emy1jpyZ9qBP/H1 u1bbx3EyiFf1JnwH2tTCbdDsq5kKbvMZgEUDDkG6swqsayTH1Su8/7dT1Y7KszOtOXek C50rpYab05R8FQ/i2MVIKXWIA8CZt4NPlB1Jsvi0TQNoG3ZWwS0aXNLx2+NO0upL161T QIjLMD7w9Bum4ytlJzVJthRNxMuQmvJZ949FhL+cg/9CS4h8sgIlLdvvY+SmL5RlNtQz 1WSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=eoNVtOJ+TPrquC9j+JiM1e8MS0ypjX7QJFLnAHWM/AI=; b=ygOw4pQF7vrdZDGQjp1KmrAjRtgDxhZHfsP9i08HalfC7JklCcSBlf/D1FWQcnY1/x QsUMZkcKXe4n2W2pKSTaAygeSX/Sv/RByYhgJp8era4VPpx0XvS8xH92fdqE0HGYmGop /HweWDITh3HNwh/L9aFWmc8nTLHKKeN6+XWBGJQ2Q3OB+XV2TOpDTwJ58u4TbadKwLt6 YVaPo7S3aFfci5eZFaV8GRBoKI3vbx/cuz6z163DZ9BilVhc1jowYxUFUcI94MH5RHiz /mlMgURr7vlWIxFs142QK/q8hZZbp+T+j3BC8EtfRAbcLb7kuZNtisKBdDXk6X81Ozq8 ylLw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 205si12905635pfx.245.2022.02.23.04.40.17; Wed, 23 Feb 2022 04:40:31 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239755AbiBWLI0 (ORCPT + 99 others); Wed, 23 Feb 2022 06:08:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45496 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239706AbiBWLIZ (ORCPT ); Wed, 23 Feb 2022 06:08:25 -0500 Received: from mx1.emlix.com (mx1.emlix.com [136.243.223.33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1537F8EB5B for ; Wed, 23 Feb 2022 03:07:57 -0800 (PST) Received: from mailer.emlix.com (unknown [81.20.119.6]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.emlix.com (Postfix) with ESMTPS id 515D95F929; Wed, 23 Feb 2022 12:07:55 +0100 (CET) From: Rolf Eike Beer To: Manivannan Sadhasivam Cc: Cristian Ciocaltea , Lee Jones , linux-actions@lists.infradead.org, linux-kernel@vger.kernel.org Subject: atc260x has broken locking Date: Wed, 23 Feb 2022 12:07:48 +0100 Message-ID: <16136311.TfV2VxeR0u@mobilepool36.emlix.com> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="nextPart1905280.viRWdgczpX"; micalg="pgp-sha256"; protocol="application/pgp-signature" X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE 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: X-Mailing-List: linux-kernel@vger.kernel.org --nextPart1905280.viRWdgczpX Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="UTF-8"; protected-headers="v1" From: Rolf Eike Beer To: Manivannan Sadhasivam Cc: Cristian Ciocaltea , Lee Jones , linux-actions@lists.infradead.org, linux-kernel@vger.kernel.org Subject: atc260x has broken locking Date: Wed, 23 Feb 2022 12:07:48 +0100 Message-ID: <16136311.TfV2VxeR0u@mobilepool36.emlix.com> When looking at this functions I found the locking to be broken for the ato= mic=20 case (comments stripped): static void regmap_lock_mutex(void *__mutex) { struct mutex *mutex =3D __mutex; if (system_state > SYSTEM_RUNNING && irqs_disabled()) mutex_trylock(mutex); else mutex_lock(mutex); } static void regmap_unlock_mutex(void *__mutex) { struct mutex *mutex =3D __mutex; mutex_unlock(mutex); } When the mutex is already locked and the atomic context is hit then the loc= k=20 will not be acquired, this is never noticed, and it afterwards is unlocked= =20 anyway. The comment says this is inspired from i2c_in_atomic_xfer_mode() to detect = the=20 atomic case, but the important caller __i2c_lock_bus_helper() actually does= =20 check and pass on the return value of mutex_trylock(), which is missing her= e. Greetings, Eike =2D-=20 Rolf Eike Beer, emlix GmbH, https://www.emlix.com =46on +49 551 30664-0, Fax +49 551 30664-11 Gothaer Platz 3, 37083 G=C3=B6ttingen, Germany Sitz der Gesellschaft: G=C3=B6ttingen, Amtsgericht G=C3=B6ttingen HR B 3160 Gesch=C3=A4ftsf=C3=BChrung: Heike Jordan, Dr. Uwe Kracke =E2=80=93 Ust-IdNr= =2E: DE 205 198 055 emlix - smart embedded open source --nextPart1905280.viRWdgczpX Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part. Content-Transfer-Encoding: 7Bit -----BEGIN PGP SIGNATURE----- iLMEAAEIAB0WIQQ/Uctzh31xzAxFCLur5FH7Xu2t/AUCYhYVhAAKCRCr5FH7Xu2t /J+7A/9yyYI6rtw0seE6T+brf2gPxfT8AN1cR6NhpG1fer66+7sZDFPD8Fcohnm1 3kNuHFnOPbArlvbqJES+XRM9l6EUcnHmZYaqwB7bGg+KkzGhAr24qdWdrchhEY/3 mapEPHpRYwIgYsudF/OEcSukQdDpdhrVFckr2GQUGdNIQ5KVoQ== =2r1T -----END PGP SIGNATURE----- --nextPart1905280.viRWdgczpX--