Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp325853pxb; Tue, 28 Sep 2021 23:28:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzeKtPYQ2d2fq5Pmg5JUgKpGHGfOaj6FtYVVq7hKn6Ik80rs02jKzKd/D/M6b2TQ/1ELl90 X-Received: by 2002:a17:90b:3882:: with SMTP id mu2mr4605414pjb.193.1632896903589; Tue, 28 Sep 2021 23:28:23 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1632896903; cv=pass; d=google.com; s=arc-20160816; b=LN6qaU4la0BDx2tqMnLCZrLwspj7O+wS9SrWS1csTJqRqn2qgmP3aNEWpCMK75ERnG rcPlJ8oVUO63m5ok82RZrEtKoovPCVDSLnvBgWQAtrQZpEc66iTvNoQiFKsJ77c6CwXw vnFpXAjfooLVgclVDxcc1jKuYSqve7zNm2LO5Ng0swptqFn8KdjF7aJpuNOBO+qCw27z mLltHvPVgQ0qGubOPtYCKBMlHpLjbrAyS38Gu2uoU8Lr2ycWAE49MBS7jdjwqSTcAEbl KVcssOQfcB6QIJRAbEBZ+QwpxQWRul3MNMVT1iLu7ACTb/nzI8SU3+GDbsSL9bWVd+XO iGuA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:in-reply-to :content-disposition:references:message-id:subject:cc:to:from:date :dkim-signature:dkim-signature; bh=cTCm3wqcqo977+EdF0rR4gATOAWbx+Ocr1vcuZk1dPE=; b=txn1YHO3yCm2Jrutt1ehFOQMqsD9yYXXvgE6ccESRE8cVX52+Edu47YoEvKefE34Jk 63f4SSAZKuNuzd5W5JCTd83fdL+Jb2KrBK+4O1YJTiwdH/znREFSAP8ay3ode2C4upfM 2CQOG3F2Ein3bX1v8c3JplMg2F+FiB8eywngYsyEkwnN/wggescODNNdLVNvt8D+KqtN bMuU7xYa9fGXy87fJMvlNpHH7t3JSS1uOZSqSAE5PRvpJRfzHkcZcuMZ3lbwU+JCwubr uTZy9DT418CPbGutww01rGwMzQTR3mUl885a82aipym3mUI6kZxsd4ZN4waVCeDvU7Lw RJsQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2021-07-09 header.b=E33udLQ2; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b="htifoA/W"; arc=pass (i=1 spf=pass spfdomain=oracle.com dkim=pass dkdomain=oracle.com dmarc=pass fromdomain=oracle.com); 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=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y10si654796pjg.107.2021.09.28.23.28.10; Tue, 28 Sep 2021 23:28:23 -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=@oracle.com header.s=corp-2021-07-09 header.b=E33udLQ2; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b="htifoA/W"; arc=pass (i=1 spf=pass spfdomain=oracle.com dkim=pass dkdomain=oracle.com dmarc=pass fromdomain=oracle.com); 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=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244349AbhI2G0q (ORCPT + 99 others); Wed, 29 Sep 2021 02:26:46 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:20458 "EHLO mx0a-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243959AbhI2G0q (ORCPT ); Wed, 29 Sep 2021 02:26:46 -0400 Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 18T4oQIK005976; Wed, 29 Sep 2021 06:22:49 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : references : content-type : in-reply-to : mime-version; s=corp-2021-07-09; bh=cTCm3wqcqo977+EdF0rR4gATOAWbx+Ocr1vcuZk1dPE=; b=E33udLQ2bCU2i40f/oC/7Bb9BKnoeytehWr2IglThra+ZRVwWlarJnn/p3mEmchy53f7 NCYKJJbj9H9nVmVYgLp4YNLfMNijq2KzsEaoTUkIkunDHw85VLG9Y30nAZfhzSmS5Ibf FSAX26Jl+5L/IGcUB3eiJo+tKy5fIAKf0TaIup9waRNW5pTJPuNYanNi8vFV2vsij8Ti HUGa/yoEYSLP9PQQVmNcmAyCwVnAWVHzOjGKto4nFYrLXtYe9umQujU/6tC2ieYveeb5 sbfr2sv6TNZ979XY6xuXsNrZiWCvdWaQ6azq/12CH9cNJBzig4nU2xatQ+3buoq2A6T7 Tw== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by mx0b-00069f02.pphosted.com with ESMTP id 3bchfkrc9x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 29 Sep 2021 06:22:48 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 18T6AQGv034629; Wed, 29 Sep 2021 06:22:47 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2105.outbound.protection.outlook.com [104.47.58.105]) by userp3030.oracle.com with ESMTP id 3bc3bjetmr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 29 Sep 2021 06:22:46 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OsOrWLyEydcLLiLFfowVw6m7ze0fLpqUvZkYrezZidHDACkegxDwzlFzbGU3PqlYONI2KUfrR5FfPfzb4+oHlVzbDdEL8m50fPRbzkYsUzVfefQe7oqb9WrVY333TNWV88Ecn4+CE7BA9qPRqfzMt92vj9y6GXVnIIMUYZreptcXrkKy+osm9RQo1zAfLQYEnU8utehIdvmimkaz8aASki3tl5mXG1eUvam1kkIzDrySVOe+9uhGYnY7ivSZIBRZZX/IpalZEqXx3HhB2Z2bH4ECCjscCIomC4eL9BInkICw66CDYRvnrhsKCwemGYEVVe5jTFgRmuTbwI93OMLzgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=cTCm3wqcqo977+EdF0rR4gATOAWbx+Ocr1vcuZk1dPE=; b=MeJ2Caw8ryd6tGVyg+c/Tas99Rsk5ppPQxcdFCwJwP3+UEzYHDvamOj+4Kk0KXTbAegPpQxNg2q+mpaZExBTKzWD9S7ymL6Wpg8ROyZVonqGwKbmqEWqI5Oba1sp5IiYDfxUf+iKtZGbCp0bJpXA7qjmTLGNotugryVVtgcltKaHIcAlGipCPZBAVMnCViFUcwLk881iGCv3IPR5NZfcHwsWbwAu+fkgAa90FGSAvogDZMTQg6lSq4NbXmLqRLKZIiRq/n5zN3Tu+s7/V0Ger5B0c/PvHKil/ZKFe3nRPYUhSciPmuZwOe+nNwuaxZd/J7lGVnBMsAmckxnoyVOxBA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=cTCm3wqcqo977+EdF0rR4gATOAWbx+Ocr1vcuZk1dPE=; b=htifoA/WKRyFLuQ6F1Z+5WHwufcj9WQl+sJGbmw7t992gN3ETJxUqCOhSgl8f3PEUm+flsHTk++sjxOpjx7BKDGuW1p07OQAx5S4+le/juAjkh6deM1DDz2FRl6PUIWuSshYmalPglVMSDwCwj2y57waCntGFjud2ip6s7Eqlt4= Authentication-Results: gmail.com; dkim=none (message not signed) header.d=none;gmail.com; dmarc=none action=none header.from=oracle.com; Received: from MWHPR1001MB2365.namprd10.prod.outlook.com (2603:10b6:301:2d::28) by CO6PR10MB5571.namprd10.prod.outlook.com (2603:10b6:303:146::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.15; Wed, 29 Sep 2021 06:22:45 +0000 Received: from MWHPR1001MB2365.namprd10.prod.outlook.com ([fe80::d409:11b5:5eb2:6be9]) by MWHPR1001MB2365.namprd10.prod.outlook.com ([fe80::d409:11b5:5eb2:6be9%5]) with mapi id 15.20.4544.021; Wed, 29 Sep 2021 06:22:45 +0000 Date: Wed, 29 Sep 2021 09:22:26 +0300 From: Dan Carpenter To: Pavel Skripkin Cc: andrew@lunn.ch, hkallweit1@gmail.com, linux@armlinux.org.uk, davem@davemloft.net, kuba@kernel.org, buytenh@marvell.com, afleming@freescale.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, syzbot+398e7dc692ddbbb4cfec@syzkaller.appspotmail.com Subject: Re: [PATCH v2 2/2] phy: mdio: fix memory leak Message-ID: <20210929062226.GR2083@kadam> References: <2324212c8d0a713eba0aae3c25635b3ca5c5243f.1632861239.git.paskripkin@gmail.com> <55e9785e2ae2eae03c4af850a07e3297c5a0b784.1632861239.git.paskripkin@gmail.com> Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <55e9785e2ae2eae03c4af850a07e3297c5a0b784.1632861239.git.paskripkin@gmail.com> User-Agent: Mutt/1.9.4 (2018-02-28) X-ClientProxiedBy: JNXP275CA0032.ZAFP275.PROD.OUTLOOK.COM (2603:1086:0:18::20) To MWHPR1001MB2365.namprd10.prod.outlook.com (2603:10b6:301:2d::28) MIME-Version: 1.0 Received: from kadam (62.8.83.99) by JNXP275CA0032.ZAFP275.PROD.OUTLOOK.COM (2603:1086:0:18::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.14 via Frontend Transport; Wed, 29 Sep 2021 06:22:39 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 247ac3ed-1719-4bfb-0d1c-08d983118ca9 X-MS-TrafficTypeDiagnostic: CO6PR10MB5571: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: B5OeiulEMKLJ+tHUwpqerfR98q47eEm6Luw/FQp1KzvdFDQa5NN4RnOXzYaU6Elry+fsjducftg9ocxVw2EvkIHkOo5z+xUdd7Ts40tTiEBp8y7bZPxeGFR7y6AGTAeIHGEuuDjx13qMCt1Leysr7sP9LWKYATtP2jstq15LWQLhtJh0ZrK+EGbuNfFZ7HfmUTV/czzQP4j44fvdZfpTqUUM4Ahf4HBP4qUT6MDFyuNkvBhZnBYTn4QMmE4ReNgOfYnCz/wrx6nDUf7CiWv6GOT5q62frs7noq97ZjKSS+xbvtm/2CxXX7U4xm58h9ImWLDRX2w4Viz5Jj5hbiGQBzEzS5J/k3c7k5DVbdUXbeUdizCBgwlsucFLT9Fr7CxH2Zp0Oery+Uzj01noh5nhhxqo6af/IelCIaQAGy7xc2YEfivQWTX5fDzUMFsFju9KSyWNhEFKZQBPGyrkVtCubBExJACcIgM+6gLOQZleXv7Sv8R2LWHgj9muEl5G+wo6Ho60liXxppVBvEKgvVbMV5X71kDTIiXgLc0UD2tR/y9SarVGRwgn2EQiWaTr4E5jEPTlpVU11luGk7Hbz8Z/k/BwDT2QaLWQXPmXo2eMcaFhdeihTYn4fs+blp6TMyPCx/N5nj+5XUb3X3t7kQZs+oc/ZOJnV2qube3ihGruv7wVTMYl5YqiNqng52EE572qGyLiE2qlG58aHl4U8sn85/jV6UgoGGxLIU7DwBoCH9CYMPHO0r5cy0nrcmNpeHxQVu7f/e1d+qfEc2JMdE5jP1Q/jDvgZru73acMY7WsV4o= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MWHPR1001MB2365.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(316002)(6666004)(966005)(86362001)(8936002)(66556008)(8676002)(66946007)(956004)(9576002)(4326008)(33656002)(66476007)(52116002)(6496006)(38100700002)(38350700002)(1076003)(508600001)(9686003)(2906002)(83380400001)(7416002)(55016002)(33716001)(26005)(44832011)(5660300002)(6916009)(186003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?ESkR/2FaC8dshSDHpShN/MqW/55/4ldrn+REMGRzStJth1C1V6bFYT6H//fh?= =?us-ascii?Q?QQOKRBuFBT2X1skOE5WUWtVPkv6BBg9kBRV1ImekVtHoZmRQmcIPr49o5HhB?= =?us-ascii?Q?QkW4/o97mrt94tPAMm7KiUoWuTQXU/nYwUzrCjUvsyOMeOYfiPzsMibIGQsQ?= =?us-ascii?Q?tvWsIZmu8eR0MbwFUX3Xd21/ma7LczfolGBTkcUGtO9d/TRBeZPHtkTqvuw/?= =?us-ascii?Q?1p9gSmsssrs5gI8sosmIIS5Azt9rSK2g9kwoT5GXpwL8OEcbyWx549JoxUNM?= =?us-ascii?Q?Vio3aOPysv+spC583KdZz0RmsGN8wTX7fFUpPXTKoiZfrn0zpnwTnEPyB1OK?= =?us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T7sqCb8B2yNrLc0jCOhh0PzwO9?= =?us-ascii?Q?gg3fN+YTyCPUhASTC5OFE11xoMwo3XOGlIryQ3GGW0L122FDAm2PsVZXudkF?= =?us-ascii?Q?txjuF32W399r1UPHz1Kc0jxI?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 247ac3ed-1719-4bfb-0d1c-08d983118ca9 X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2365.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Sep 2021 06:22:45.2014 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: X0egyFbPT4tQNBC6Mre+4XwqvrJPrG9V4Jpm1tqCsSlvliUAHYSTU35YpD91k4jOLGn3QkboRV/+iVt3TYS3X0f+9R7VIRjuwmYxyoWsOO8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO6PR10MB5571 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10121 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 suspectscore=0 mlxscore=0 spamscore=0 adultscore=0 bulkscore=0 phishscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2109230001 definitions=main-2109290037 X-Proofpoint-ORIG-GUID: TD63KVpMhPvADrFqekozpQtnKqzgUspl X-Proofpoint-GUID: TD63KVpMhPvADrFqekozpQtnKqzgUspl Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Sep 28, 2021 at 11:40:15PM +0300, Pavel Skripkin wrote: > Syzbot reported memory leak in MDIO bus interface, the problem was in > wrong state logic. > > MDIOBUS_ALLOCATED indicates 2 states: > 1. Bus is only allocated > 2. Bus allocated and __mdiobus_register() fails, but > device_register() was called > > In case of device_register() has been called we should call put_device() > to correctly free the memory allocated for this device, but mdiobus_free() > calls just kfree(dev) in case of MDIOBUS_ALLOCATED state > > To avoid this behaviour we need to set bus->state to MDIOBUS_UNREGISTERED > _before_ calling device_register(), because put_device() should be > called even in case of device_register() failure. > > Link: https://lore.kernel.org/netdev/YVMRWNDZDUOvQjHL@shell.armlinux.org.uk/ > Fixes: 46abc02175b3 ("phylib: give mdio buses a device tree presence") > Reported-and-tested-by: syzbot+398e7dc692ddbbb4cfec@syzkaller.appspotmail.com > Signed-off-by: Pavel Skripkin Thanks! Reviewed-by: Dan Carpenter regards, dan carpenter