Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp410760pxy; Wed, 28 Apr 2021 06:50:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzBQEb9fx0/mZPXufdMALdlxrdoob9XwLbNYW1pSjEvuUbwUZ3zkd5fHh0my/L8BDnUehKt X-Received: by 2002:aa7:860f:0:b029:265:4428:3104 with SMTP id p15-20020aa7860f0000b029026544283104mr27762532pfn.75.1619617814529; Wed, 28 Apr 2021 06:50:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619617814; cv=none; d=google.com; s=arc-20160816; b=EzN/9Smd93wAjbR3c4uNiNjkeuuuT+IqN/ZoxE/HxLCnjqJNgROjSm97q9CO4T8s8v ngvKhjStuHecGvJnUK1PExj8D+r9MgEGIKTOgehy5Mv01egmPQRbHm08pV5117o6vZET czxcX6b67OmS7S8e2QdxWzgEfABCHz/CXtSPpjJ8VlxB4ZZeh5idi3gnkdYM+yqR8dZc HptiuIo3I+QZW79ug5J49ROD5mS+K4KSKt3vQBO73mBzOA01YpPTVXM55h+gpqATMAbk Vt1c7Vbwt8rpEZjizd3VOpOOTav+FQeOvRJFj1R9UZw2wIsYR/jz06o2oAw0gxBM76rN VC3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=XGpsFivWxEXvS6dSn28G4U9xlQVBMxflLrlRvG8D1jc=; b=r4xR9DiweXoC/qaalPn4/3ns6zHi4TcOPVZHwFE5KHayzs1Ka2n2CbtBkpurfP0Dw5 0MBmmf7lVJyKRhpxrXSlNY46SsIkysmjoSbNj+KF2U1ubQyQ0OpSM/7CKO/JhGUhKA6/ 25E+2QONoyj6cHzNSqzsGe0Sb06T6UonT7uKrPghg/Md45BYepTwXe7NotViE0HMHPKF VPRbs+2HMVsZZvuIFvsiZj6aRdTRp7ykDThLwJtCIQgvIraR228RPE1bCA/ef3u1YY4d MNY6nL0/rII66StuUvKAAGFK6ugRBtDT3UlKCWoHeLgUf1zl5hEVPe7liBiTM9U4fTva yr9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jVifndFD; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q17si3692137plk.424.2021.04.28.06.50.01; Wed, 28 Apr 2021 06:50:14 -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=@kernel.org header.s=k20201202 header.b=jVifndFD; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234780AbhD1MWs (ORCPT + 99 others); Wed, 28 Apr 2021 08:22:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:55058 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234356AbhD1MWr (ORCPT ); Wed, 28 Apr 2021 08:22:47 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8375961413; Wed, 28 Apr 2021 12:22:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1619612522; bh=0yfljeWZf/as7id/4Rzh3FTtgepJ+ZlD02AKERVNKqg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=jVifndFDWJO/+GH5bcXQ7bxdkv+S5kJ0UicYordngtWO8yRrwI5QdlRCBukK9sZ2N OC4ggMRYH8P5ie9AhCiHcXA8UdgLcbXDd3q6O0HIfyoDSGYgg7LBcipPYo9DPjePr7 0i+H4JblAAfSDDa9GHI/K35unnKX6mDtzZq5mXixEnCMqy/vT9FF83FxwOfwKc6i09 hLQ/iewqS/9TZNYrQY0rjRya6nVhQ0IvncI6C3dHZ+eJka8vUx0I9IkosoYuPAmXkQ bZDGUbiSjiv/hBhnR4Uij06meZ4UnS9ta4hFLBCuQ5f8axNt+Mf59nl0a5edWMh2oh QoAZFs/DMnXSw== Date: Wed, 28 Apr 2021 15:21:55 +0300 From: Leon Romanovsky To: Jaroslav Kysela Cc: bkkarthik , Anupama K Patil , "Rafael J. Wysocki" , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, skhan@linuxfoundation.org, gregkh@linuxfoundation.org, kernelnewbies@kernelnewbies.org Subject: Re: [PATCH] drivers: pnp: proc.c: Handle errors while attaching devices Message-ID: References: <20210424194301.jmsqpycvsm7izbk3@ubuntu> <20210426175031.w26ovnffjiow346h@burgerking> <59a5d631-6658-2034-06c4-467520b5b9f7@perex.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <59a5d631-6658-2034-06c4-467520b5b9f7@perex.cz> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Apr 28, 2021 at 02:04:49PM +0200, Jaroslav Kysela wrote: > Dne 26. 04. 21 v 19:50 bkkarthik napsal(a): > > On 21/04/26 08:04AM, Leon Romanovsky wrote: > >> On Sun, Apr 25, 2021 at 01:13:01AM +0530, Anupama K Patil wrote: > >>> isapnp_proc_init() does not look at the return value from > >>> isapnp_proc_attach_device(). Check for this return value in > >>> isapnp_proc_detach_device(). > >>> > >>> Cleanup in isapnp_proc_detach_device and > >>> isapnp_proc_detach_bus() for cleanup. > >>> > >>> Changed sprintf() to the kernel-space function scnprintf() as it returns > >>> the actual number of bytes written. > >>> > >>> Removed unnecessary variables de, e of type 'struct proc_dir_entry' to > >>> save memory. > >> > >> What exactly do you fix for such an old code? > > > > I was not aware that this code is so old. This fix was made after checkpatch reported assignment inside an if-statement. > > Please ignore this patch if th change is not necessary as the code is probably not being used anywhere :) > > > > Maybe the code has to be marked as obsolete in the MAINTAINERS file to prevent patches being sent? > > > >> > >>> > >>> Suggested-by: Shuah Khan > >>> Co-developed-by: B K Karthik > >>> Signed-off-by: B K Karthik > >>> Signed-off-by: Anupama K Patil > >>> --- > >>> drivers/pnp/isapnp/proc.c | 40 +++++++++++++++++++++++++++++---------- > >>> 1 file changed, 30 insertions(+), 10 deletions(-) > >>> > >>> diff --git a/drivers/pnp/isapnp/proc.c b/drivers/pnp/isapnp/proc.c > >>> index 785a796430fa..46ebc24175b7 100644 > >>> --- a/drivers/pnp/isapnp/proc.c > >>> +++ b/drivers/pnp/isapnp/proc.c > >>> @@ -54,34 +54,54 @@ static const struct proc_ops isapnp_proc_bus_proc_ops = { > >>> .proc_read = isapnp_proc_bus_read, > >>> }; > >>> > >>> +static int isapnp_proc_detach_device(struct pnp_dev *dev) > >>> +{ > >>> + proc_remove(dev->procent); > >>> + dev->procent = NULL; > >>> + return 0; > >>> +} > >>> + > >>> +static int isapnp_proc_detach_bus(struct pnp_card *bus) > >>> +{ > >>> + proc_remove(bus->procdir); > >>> + return 0; > >>> +} > >> > >> Please don't add one line functions that are called only once and have > >> return value that no one care about it. > > > > These were only intended for a clean-up job, the idea of this function came from how PCI handles procfs. > > Maybe those should be changed? > > Which code you refer? I see: > > for_each_pci_dev(dev) > pci_proc_attach_device(dev); He talks about isapnp_proc_detach_*() functions. > > > The error codes are ignored, too. It does not harm, if proc entries are not > created (in this case - the system is unstable anyway). We should concentrate > only to the wrong pointers usage. > > Jaroslav > > -- > Jaroslav Kysela > Linux Sound Maintainer; ALSA Project; Red Hat, Inc.