From: Benjamin Marzinski Subject: Re: [PATCH 07/14] libmultipath: check return value of dm_mapname in, sysfs_check_holders Date: Fri, 4 Sep 2020 15:28:27 -0500 Message-ID: <20200904202827.GC11108@octiron.msp.redhat.com> References: <37544d4c-950f-4281-3b66-e4d1884c5167@huawei.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com Content-Disposition: inline To: lixiaokeng Cc: linfeilong , dm-devel mailing list , Martin Wilck , "liuzhiqiang (I)" List-Id: dm-devel.ids On Wed, Sep 02, 2020 at 03:19:51PM +0800, lixiaokeng wrote: > In sysfs_check_holders func, table_name is obtained by calling > dm_mapname func, and then call dm_reassign_table for reassigning > table. However, we donnot check whether dm_mapname func returns > NULL, and then it may cause a segmentation fault in dm_task_set_name. > > Here, we will check whether dm_mapname func returns NULL before > using it. Reviewed-by: Benjamin Marzinski > > Signed-off-by: Zhiqiang Liu > Signed-off-by: Lixiaokeng > --- > libmultipath/sysfs.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/libmultipath/sysfs.c b/libmultipath/sysfs.c > index 12a82d95..5390de62 100644 > --- a/libmultipath/sysfs.c > +++ b/libmultipath/sysfs.c > @@ -278,7 +278,11 @@ int sysfs_check_holders(char * check_devt, char * new_devt) > continue; > } > table_name = dm_mapname(major, table_minor); > - > + if (!table_name) { > + condlog(2, "%s: mapname not found for %d:%d", check_dev, > + major, table_minor); > + continue; > + } > condlog(0, "%s: reassign table %s old %s new %s", check_dev, > table_name, check_devt, new_devt); > > --