Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp4412637rdh; Wed, 29 Nov 2023 00:11:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IE712/Q30xAfCetVBOVenIMJmzV0+QAO2ykUM56+1JQOnLgNLr8iPXie5+TqXD4wXia+K8O X-Received: by 2002:a05:6a20:7f83:b0:187:c3db:8999 with SMTP id d3-20020a056a207f8300b00187c3db8999mr22250195pzj.45.1701245492238; Wed, 29 Nov 2023 00:11:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701245492; cv=none; d=google.com; s=arc-20160816; b=Dxsi/7vtpfBmIfv8WzS/a2QI8lm4IJxauXK4mxBsxbzDqcQR9bIDnoxBYKmScbTwMb klB6jsc6VZKDTDIlk0aDkR7+zCCsl9x88Ec9GK/NiwgBiI/sC84yZgU5o60Wg4PyFFrx IukyYwU9K9jiiPgWMcnJxGN+JQT42cKKtg4d/N5iFJcm3kfGs3Yz3DnlfKJDr3wgFnyw Xcqt8VvrA/BcElcmzywj7H4A5TeKTJztZPQ1xhQmr0pyqv0GTM//3Qjgwo2o6/0Pm8vh pkdgRDB0O5/2f8lBk3i9UIgqeUn3C1fQS+WTkxXwuMoj4DUny7dwfgM6333EDCI3gSFA TSnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version; bh=F6fisQ+tBpvM7kunR4eavitqhPZfoDadzRkczDlcyfc=; fh=8dGxMbuJFEL5hxPQ5h9hBu647A6oFNmggQplMYdmJDM=; b=FfhVO0JTB6mN+PfYR/CymdThnNWWNLVRQZa07m/mm3Ai7C99Nx535edqXkn3xBBjx+ E6zAEAjLCYeDGXgTye08RkeQv96Gx3E7Gsa3zGvBH5pwjy+LZUE8xaHSBeGwhJd+Sbgg d0lOKe0Z7RDtm+ZOmYaI88p4h3F0G4V6+1bYSwqgwwHjkP11rWXh+uQQRrV2odA+CwCt j/iW+3DXWSC8ZocpCkTZ7PgK4jdQ8r89bPIuyOK6yOMCUDTSHGqd+WS6xRUJYpVy3VZt QlrejMZu2C+cB5VOjMhlB0N4LnhVR9/CFUXcc9p/t19IeFcTE2EOrdChLafygVIg6seT NhJA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id q13-20020a17090a304d00b0027d2db562d2si820970pjl.161.2023.11.29.00.11.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 00:11:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 9613480A97C6; Wed, 29 Nov 2023 00:11:25 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231795AbjK2IKx convert rfc822-to-8bit (ORCPT + 99 others); Wed, 29 Nov 2023 03:10:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49822 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231596AbjK2IKu (ORCPT ); Wed, 29 Nov 2023 03:10:50 -0500 Received: from mail-yw1-f176.google.com (mail-yw1-f176.google.com [209.85.128.176]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 381FF19BA; Wed, 29 Nov 2023 00:10:55 -0800 (PST) Received: by mail-yw1-f176.google.com with SMTP id 00721157ae682-5d28f5bbd6cso1597817b3.1; Wed, 29 Nov 2023 00:10:55 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701245454; x=1701850254; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=i5ZLV3/lGWkTPqqCKMiKC0kF/REvnd+ju384kw/YGc8=; b=fLq8nWa8ilZOs7/AkxKRSE/qxC0qD0nb6hfh4qKIfjKYkPLlsuOOyB2tWFIrOuSEXe YcaITg3xM0VgdBu4HRobXIosDb0z2bZTBvKrpkcJvQwhcHj5Atb7s1JnT5cVD1WvGCIq XJjXWRCKOwTPx0i5zdla53C+F+L+BSAUR6cA9jia4H5Gj+VsusVYdWbvCr5S2xprdPMv XlaTHrlxjZdwXW735o6cQxFl4cXxH758CcCWfPiwgo8yKuhWIWyINRuZ9uXGzTRIHt7r TG2ftUZgs6NYQURHKQjdYY52WKlXBQQzLHFA3cueeWvBQwPYpB9vnW9GKOUPIAYcE+nm iEYg== X-Gm-Message-State: AOJu0Ywv1VzXjn39cmvOg+MkfNCEqeQETkjkOgviVUweThornzgQhk+d gJDHmE9fNWA/kKY5kYWGjNlPiP19fQcNgw== X-Received: by 2002:a81:5f03:0:b0:5b3:3eb5:6624 with SMTP id t3-20020a815f03000000b005b33eb56624mr16210277ywb.46.1701245454188; Wed, 29 Nov 2023 00:10:54 -0800 (PST) Received: from mail-yw1-f179.google.com (mail-yw1-f179.google.com. [209.85.128.179]) by smtp.gmail.com with ESMTPSA id g184-20020a0dc4c1000000b0059b17647dcbsm4374185ywd.69.2023.11.29.00.10.53 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 29 Nov 2023 00:10:53 -0800 (PST) Received: by mail-yw1-f179.google.com with SMTP id 00721157ae682-5cc86fcea4fso54302467b3.3; Wed, 29 Nov 2023 00:10:53 -0800 (PST) X-Received: by 2002:a05:690c:4805:b0:5cf:806f:49fd with SMTP id hc5-20020a05690c480500b005cf806f49fdmr11825321ywb.44.1701245453396; Wed, 29 Nov 2023 00:10:53 -0800 (PST) MIME-Version: 1.0 References: <20231129063730.31184-1-liuhaoran14@163.com> In-Reply-To: <20231129063730.31184-1-liuhaoran14@163.com> From: Geert Uytterhoeven Date: Wed, 29 Nov 2023 09:10:41 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] [sh/highlander] psw: Add error handling in psw_irq_handler To: Haoran Liu Cc: ysato@users.sourceforge.jp, dalias@libc.org, glaubitz@physik.fu-berlin.de, linux-sh@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Wed, 29 Nov 2023 00:11:26 -0800 (PST) Hi Haoran, On Wed, Nov 29, 2023 at 7:38 AM Haoran Liu wrote: > This patch adds error handling for the platform_get_drvdata call > within the psw_irq_handler function in > arch/sh/boards/mach-highlander/psw.c. Previously, the absence of > error checking could lead to unexpected behavior if > platform_get_drvdata returned a null pointer. > > Signed-off-by: Haoran Liu Thanks for your patch! > --- a/arch/sh/boards/mach-highlander/psw.c > +++ b/arch/sh/boards/mach-highlander/psw.c > @@ -21,6 +21,12 @@ static irqreturn_t psw_irq_handler(int irq, void *arg) > unsigned int l, mask; > int ret = 0; > > + if (!psw) { > + pr_err("psw_irq_handler: No push_switch data associated > + with platform_device\n"); > + return IRQ_NONE; > + } > + > l = __raw_readw(PA_DBSW); > > /* Nothing to do if there's no state change */ This means the button is pressed, and the interrupt fired, in between the calls to request_irq() and platform_set_drvdata() in arch/sh/drivers/push-switch.c:switch_drv_probe()? The same issue can happen with arch/sh/boards/mach-landisk/psw.c. I think the proper solution is to fix this inside the push switch driver, by moving the call to request_irq() after the call to platform_set_drvdata() (and doing the reverse in switch_drv_remove()). Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds