Message ID | 20231128130952.3372794-1-harshit.m.mogalapalli@oracle.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce62:0:b0:403:3b70:6f57 with SMTP id o2csp3905756vqx; Tue, 28 Nov 2023 05:10:23 -0800 (PST) X-Google-Smtp-Source: AGHT+IFq/wDmUoXhJRsuttHjyHkQ7eLLioTXRXRHp9YOtz6OFHMz4+FPvLqatvscOtEWzmgyQAKt X-Received: by 2002:a05:6870:d911:b0:1f4:be52:b129 with SMTP id gq17-20020a056870d91100b001f4be52b129mr19412559oab.56.1701177023380; Tue, 28 Nov 2023 05:10:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701177023; cv=none; d=google.com; s=arc-20160816; b=N/DfgeOZD5z9HOF5rBb0UeuF4hyBeiKkMHoePTNS5QjTuF6EUL7BvuH5IpD50Ea/+2 GpkYZ4adWEyyIXtE+Ih+sscN/Crpy98xA2YWiGJtP0UwljdoHya7hL18D4/b/WECSqVN mVIgV85kph++iu8ROFs6AR8N0MN7pz46GvG4814I9YlCvUjTfWpgVUw4GKs0mdsy0GLi tggrL/2IAYK7GGDHawGEOOkoAIlPNmUv65xSaS0+IBq57/IInQ22ig51IMNf2zj3Sg9c opMx/f3MHZDXbBsi+AGMPuviASIqZmkMRV3nUiDbmFXx+f1aC3cISpTaOXeC1n3X2Auo ncyA== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=BzNJ9iRGfz25bP31jKWHUOIixIrbax65I5/G31Hvt9w=; fh=HwsKBgO84BpY/XE0B+pTAbQo9XTqzaM3c7ZGojTa4EU=; b=wpz0NpIg2w2/AKxNY/v3N9vn0BG5j3peL1Mwz/NAnQGM+4o4HD9eAfUNwKcLlkOH8k r+YJ167813e5mEldLPZYgSEIcng+GYzaWGTVLjUq9lzoAzEEmRaeymY7oEpnVckk8uUM bdmEKj32BTPxiYCFESwXRRRF/k/PLzi/AlGrF06pYyxp/tLhfnlDGPKQ9gDja1gqzU6l m2pkOJBYX+WbdwETep4ZjBshIhfwCWMCW2GZrnxMfgrsDJ6weRJnWsXqXzSXBNHtmg9A AW78xJiBLlNz9pkIGcdUuOEMjps/exzpHZr0tHXznubq70pbKVrkBY5o6hgnp5pcII0E MpCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-11-20 header.b=bxTo9+80; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id na20-20020a0568706c1400b001fa4ab7a779si1913588oab.261.2023.11.28.05.10.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 05:10:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-11-20 header.b=bxTo9+80; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 0DFFB8049213; Tue, 28 Nov 2023 05:10:22 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344891AbjK1NKL (ORCPT <rfc822;toshivichauhan@gmail.com> + 99 others); Tue, 28 Nov 2023 08:10:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36218 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344871AbjK1NKJ (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 28 Nov 2023 08:10:09 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C60BD51; Tue, 28 Nov 2023 05:10:16 -0800 (PST) Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3ASBT54N000874; Tue, 28 Nov 2023 13:09:58 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding; s=corp-2023-11-20; bh=BzNJ9iRGfz25bP31jKWHUOIixIrbax65I5/G31Hvt9w=; b=bxTo9+80AYbBVv/Kv7UPx0/iXHVVu2a993TxlSvclY+1J1j5/O3pmGUw2d7QKJc6d+On lsm7lEMkO5knNkvIP4IDQGTelfq3zp9Fk2Nkn6LjnqefgcyZPsdvsPjIsIw1vgEhdj99 +W+VBKg3LQUSFUnxsFVfhzdlN9zVN0Wu617l3XL86ltVgIUCUXHZcvxQHfM4G+8BXjo6 zkWwp9DQFrNCtvE5wazZw2tPPG9/RhpZr7CNUp2Q5eMTTNScR7msIDoSspozSqs1YiT6 iZ72fYFZ1sfdgEDQbIgRUDmNP7xXhpCQZaYU4R8qagV9WfZhwTjO9auU/DDc8DHw5gmj CQ== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3uk8yd5rqa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 28 Nov 2023 13:09:58 +0000 Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 3ASD0uB9027071; Tue, 28 Nov 2023 13:09:57 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3uk7cd34ne-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 28 Nov 2023 13:09:57 +0000 Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3ASD9vau005694; Tue, 28 Nov 2023 13:09:57 GMT Received: from ca-dev112.us.oracle.com (ca-dev112.us.oracle.com [10.129.136.47]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 3uk7cd34m3-1; Tue, 28 Nov 2023 13:09:57 +0000 From: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com> To: Borislav Petkov <bp@alien8.de>, Tony Luck <tony.luck@intel.com>, James Morse <james.morse@arm.com>, Mauro Carvalho Chehab <mchehab@kernel.org>, Robert Richter <rric@kernel.org>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, linux-edac@vger.kernel.org, linux-kernel@vger.kernel.org Cc: dan.carpenter@linaro.org, kernel-janitors@vger.kernel.org, error27@gmail.com, harshit.m.mogalapalli@oracle.com Subject: [PATCH] EDAC/sysfs: Fix calling kobject_put() without kobj initialization Date: Tue, 28 Nov 2023 05:09:52 -0800 Message-ID: <20231128130952.3372794-1-harshit.m.mogalapalli@oracle.com> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-28_14,2023-11-27_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 malwarescore=0 suspectscore=0 spamscore=0 mlxlogscore=999 mlxscore=0 phishscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2311280105 X-Proofpoint-ORIG-GUID: OjPUr0MfaKZ5C1yf0Hi4U5w1zAH6OmQ9 X-Proofpoint-GUID: OjPUr0MfaKZ5C1yf0Hi4U5w1zAH6OmQ9 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 28 Nov 2023 05:10:22 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783813398529968389 X-GMAIL-MSGID: 1783813398529968389 |
Series |
EDAC/sysfs: Fix calling kobject_put() without kobj initialization
|
|
Commit Message
Harshit Mogalapalli
Nov. 28, 2023, 1:09 p.m. UTC
In edac_pci_main_kobj_setup() when dev_root is NULL,
kobject_init_and_add() is not called.
if (err) { // err = -ENODEV;
edac_dbg(1, "Failed to register '.../edac/pci'\n");
goto kobject_init_and_add_fail; // call to kobject_put()
}
This will cause a runtime warning in kobject_put() if the above happens.
Warning:
"kobject: '%s' (%p): is not initialized, yet kobject_put() is being called."
Fix the error handling to avoid the above possible situation.
Fixes: cb4a0bec0bb9 ("EDAC/sysfs: move to use bus_get_dev_root()")
Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
---
This is based on static analysis with Smatch and only compile tested.
---
drivers/edac/edac_pci_sysfs.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
Comments
On Tue, Nov 28, 2023 at 05:09:52AM -0800, Harshit Mogalapalli wrote: > In edac_pci_main_kobj_setup() when dev_root is NULL, > kobject_init_and_add() is not called. > > if (err) { // err = -ENODEV; > edac_dbg(1, "Failed to register '.../edac/pci'\n"); > goto kobject_init_and_add_fail; // call to kobject_put() > } > > This will cause a runtime warning in kobject_put() if the above happens. > Warning: > "kobject: '%s' (%p): is not initialized, yet kobject_put() is being called." > > Fix the error handling to avoid the above possible situation. > > Fixes: cb4a0bec0bb9 ("EDAC/sysfs: move to use bus_get_dev_root()") > Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com> > --- > This is based on static analysis with Smatch and only compile tested. > --- > drivers/edac/edac_pci_sysfs.c | 14 ++++++++------ > 1 file changed, 8 insertions(+), 6 deletions(-) > > diff --git a/drivers/edac/edac_pci_sysfs.c b/drivers/edac/edac_pci_sysfs.c > index 901d4cd3ca38..71a0d4b9c2cf 100644 > --- a/drivers/edac/edac_pci_sysfs.c > +++ b/drivers/edac/edac_pci_sysfs.c > @@ -370,12 +370,14 @@ static int edac_pci_main_kobj_setup(void) > > /* Instanstiate the pci object */ > dev_root = bus_get_dev_root(edac_subsys); > - if (dev_root) { > - err = kobject_init_and_add(edac_pci_top_main_kobj, > - &ktype_edac_pci_main_kobj, > - &dev_root->kobj, "pci"); > - put_device(dev_root); > - } > + if (!dev_root) > + goto kzalloc_fail; > + > + err = kobject_init_and_add(edac_pci_top_main_kobj, > + &ktype_edac_pci_main_kobj, > + &dev_root->kobj, "pci"); > + put_device(dev_root); > + > if (err) { > edac_dbg(1, "Failed to register '.../edac/pci'\n"); > goto kobject_init_and_add_fail; > -- > 2.39.3 > Hi, This is the friendly patch-bot of Greg Kroah-Hartman. You have sent him a patch that has triggered this response. He used to manually respond to these common problems, but in order to save his sanity (he kept writing the same thing over and over, yet to different people), I was created. Hopefully you will not take offence and will fix the problem in your patch and resubmit it so that it can be accepted into the Linux kernel tree. You are receiving this message because of the following common error(s) as indicated below: - This looks like a new version of a previously submitted patch, but you did not list below the --- line any changes from the previous version. Please read the section entitled "The canonical patch format" in the kernel file, Documentation/process/submitting-patches.rst for what needs to be done here to properly describe this. - You have marked a patch with a "Fixes:" tag for a commit that is in an older released kernel, yet you do not have a cc: stable line in the signed-off-by area at all, which means that the patch will not be applied to any older kernel releases. To properly fix this, please follow the documented rules in the Documentation/process/stable-kernel-rules.rst file for how to resolve this. If you wish to discuss this problem further, or you have questions about how to resolve this issue, please feel free to respond to this email and Greg will reply once he has dug out from the pending patches received from other developers. thanks, greg k-h's patch email bot
Hi Greg, On 28/11/23 9:58 pm, Greg Kroah-Hartman wrote: > On Tue, Nov 28, 2023 at 05:09:52AM -0800, Harshit Mogalapalli wrote: >> In edac_pci_main_kobj_setup() when dev_root is NULL, >> kobject_init_and_add() is not called. >> >> if (err) { // err = -ENODEV; >> edac_dbg(1, "Failed to register '.../edac/pci'\n"); >> goto kobject_init_and_add_fail; // call to kobject_put() >> } >> >> This will cause a runtime warning in kobject_put() if the above happens. >> Warning: >> "kobject: '%s' (%p): is not initialized, yet kobject_put() is being called." >> >> Fix the error handling to avoid the above possible situation. >> >> Fixes: cb4a0bec0bb9 ("EDAC/sysfs: move to use bus_get_dev_root()") >> Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com> >> --- >> This is based on static analysis with Smatch and only compile tested. >> --- >> drivers/edac/edac_pci_sysfs.c | 14 ++++++++------ >> 1 file changed, 8 insertions(+), 6 deletions(-) >> >> diff --git a/drivers/edac/edac_pci_sysfs.c b/drivers/edac/edac_pci_sysfs.c >> index 901d4cd3ca38..71a0d4b9c2cf 100644 >> --- a/drivers/edac/edac_pci_sysfs.c >> +++ b/drivers/edac/edac_pci_sysfs.c >> @@ -370,12 +370,14 @@ static int edac_pci_main_kobj_setup(void) >> >> /* Instanstiate the pci object */ >> dev_root = bus_get_dev_root(edac_subsys); >> - if (dev_root) { >> - err = kobject_init_and_add(edac_pci_top_main_kobj, >> - &ktype_edac_pci_main_kobj, >> - &dev_root->kobj, "pci"); >> - put_device(dev_root); >> - } >> + if (!dev_root) >> + goto kzalloc_fail; >> + >> + err = kobject_init_and_add(edac_pci_top_main_kobj, >> + &ktype_edac_pci_main_kobj, >> + &dev_root->kobj, "pci"); >> + put_device(dev_root); >> + >> if (err) { >> edac_dbg(1, "Failed to register '.../edac/pci'\n"); >> goto kobject_init_and_add_fail; >> -- >> 2.39.3 >> > > Hi, > > This is the friendly patch-bot of Greg Kroah-Hartman. You have sent him > a patch that has triggered this response. He used to manually respond > to these common problems, but in order to save his sanity (he kept > writing the same thing over and over, yet to different people), I was > created. Hopefully you will not take offence and will fix the problem > in your patch and resubmit it so that it can be accepted into the Linux > kernel tree. > > You are receiving this message because of the following common error(s) > as indicated below: > > - This looks like a new version of a previously submitted patch, but you > did not list below the --- line any changes from the previous version. > Please read the section entitled "The canonical patch format" in the > kernel file, Documentation/process/submitting-patches.rst for what > needs to be done here to properly describe this. > > - You have marked a patch with a "Fixes:" tag for a commit that is in an > older released kernel, yet you do not have a cc: stable line in the > signed-off-by area at all, which means that the patch will not be > applied to any older kernel releases. To properly fix this, please > follow the documented rules in the > Documentation/process/stable-kernel-rules.rst file for how to resolve > this. > > If you wish to discuss this problem further, or you have questions about > how to resolve this issue, please feel free to respond to this email and > Greg will reply once he has dug out from the pending patches received > from other developers. No, this is a similar bug but in the edac_pci_sysfs.c file instead of the edac_device_sysfs.c. Let me resend these two patches as a patchset and change the subject to make it more obvious(EDAC/pci_sysfs, EDAC/device_sysfs in title). And add a CC stable tag. Thanks, Harshit > > thanks, > > greg k-h's patch email bot
Hi Greg, On 28/11/23 11:25 pm, Harshit Mogalapalli wrote: > Hi Greg, > > >> This is the friendly patch-bot of Greg Kroah-Hartman. You have sent him >> a patch that has triggered this response. He used to manually respond >> to these common problems, but in order to save his sanity (he kept >> writing the same thing over and over, yet to different people), I was >> created. Hopefully you will not take offence and will fix the problem >> in your patch and resubmit it so that it can be accepted into the Linux >> kernel tree. >> >> You are receiving this message because of the following common error(s) >> as indicated below: >> >> - This looks like a new version of a previously submitted patch, but you >> did not list below the --- line any changes from the previous version. >> Please read the section entitled "The canonical patch format" in the >> kernel file, Documentation/process/submitting-patches.rst for what >> needs to be done here to properly describe this. >> >> - You have marked a patch with a "Fixes:" tag for a commit that is in an >> older released kernel, yet you do not have a cc: stable line in the >> signed-off-by area at all, which means that the patch will not be >> applied to any older kernel releases. To properly fix this, please >> follow the documented rules in the >> Documentation/process/stable-kernel-rules.rst file for how to resolve >> this. >> >> If you wish to discuss this problem further, or you have questions about >> how to resolve this issue, please feel free to respond to this email and >> Greg will reply once he has dug out from the pending patches received >> from other developers. > > No, this is a similar bug but in the edac_pci_sysfs.c file instead of > the edac_device_sysfs.c. > > Let me resend these two patches as a patchset and change the subject to > make it more obvious(EDAC/pci_sysfs, EDAC/device_sysfs in title). And > add a CC stable tag. > Sent a V2 here as a patch series: https://lore.kernel.org/all/20231128183037.3395755-1-harshit.m.mogalapalli@oracle.com/ Thanks, Harshit > Thanks, > Harshit > >> >> thanks, >> >> greg k-h's patch email bot >
diff --git a/drivers/edac/edac_pci_sysfs.c b/drivers/edac/edac_pci_sysfs.c index 901d4cd3ca38..71a0d4b9c2cf 100644 --- a/drivers/edac/edac_pci_sysfs.c +++ b/drivers/edac/edac_pci_sysfs.c @@ -370,12 +370,14 @@ static int edac_pci_main_kobj_setup(void) /* Instanstiate the pci object */ dev_root = bus_get_dev_root(edac_subsys); - if (dev_root) { - err = kobject_init_and_add(edac_pci_top_main_kobj, - &ktype_edac_pci_main_kobj, - &dev_root->kobj, "pci"); - put_device(dev_root); - } + if (!dev_root) + goto kzalloc_fail; + + err = kobject_init_and_add(edac_pci_top_main_kobj, + &ktype_edac_pci_main_kobj, + &dev_root->kobj, "pci"); + put_device(dev_root); + if (err) { edac_dbg(1, "Failed to register '.../edac/pci'\n"); goto kobject_init_and_add_fail;