Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp10844785ybi; Thu, 25 Jul 2019 06:04:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqzPzZIneiMDoKXSmwcTIg9XFHYAQvdczcFOO4XPP4NlbQkTlOtCWoYyDTY/jhtQf5HNCCCn X-Received: by 2002:a17:902:6a87:: with SMTP id n7mr89524893plk.336.1564059858554; Thu, 25 Jul 2019 06:04:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564059858; cv=none; d=google.com; s=arc-20160816; b=hhJZmCEYNZvuKrPyWI3/gvvaY5plUetfzq9L7M3pu4edf8+qVHY2l7Mul4U5WgYlLu x1rgXJrGfsBQD5ED2GhUWpTbpmn5QxqwCvB492SGZzP936r8tIyx0VktTUCYiSgxqlis sjh95VVoXIw9vQ3MCwx8432gFt98QqHiYHSZnYCHRo8/epuUJWb1Zl59SjtiINidxkwf PvH7N4uf7WlbuHoTyL0iKjrYHOjUrZElqo/QWvP/jhub52aO8xFloX0dXGpJPyCqySpc h8UnrGrlY0i5KTyZH2UJgMfwKn8WQJmaqpR1Uyid5bCwjU5sHopI661JfzwmzZqMZ7I0 W5mQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:mime-version:user-agent:date:message-id :cc:to:subject:from:dkim-signature; bh=oZSwNDTQE6wHoAx64RntiWGx7Zw6F6VIIKSpa+cvjO0=; b=pFB0I6iDmdnrn3qYRyRPckxzlmsA+cUcaL7+NAIdtwXgMeZ9JJzp0tQgjlSOM8zDRM Cnge85IBZMPsB8wyVVLfu+1ATg+8hKDcfZd0dvDjcR9J97cf/ZOVpdpJq4e2+tQIazgT BDdNSsTVSgmOCWXWN13oPrwxBOUxqYft/JTrJfKv0sASwBzoa+EtHdRIzq1lxHtpJOhL 97g8NyBJKL5U1G2uqXOJFtGNynCH2Rp1o3HR1LU61c1oO+hhT+hbpJi3eF91qyyeij/u nghyMzygdXNimDfNOLv/kSCK6Zid0HK2Hs63YaKxdDgr8BE/QmlEXI4Ac2ESFY+eYKcz BzHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=mjm595ix; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p13si16223217plo.33.2019.07.25.06.04.01; Thu, 25 Jul 2019 06:04:18 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=mjm595ix; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388278AbfGYJtq (ORCPT + 99 others); Thu, 25 Jul 2019 05:49:46 -0400 Received: from mail-pg1-f169.google.com ([209.85.215.169]:36108 "EHLO mail-pg1-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725808AbfGYJtp (ORCPT ); Thu, 25 Jul 2019 05:49:45 -0400 Received: by mail-pg1-f169.google.com with SMTP id l21so22764056pgm.3 for ; Thu, 25 Jul 2019 02:49:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:subject:to:cc:message-id:date:user-agent:mime-version :content-transfer-encoding:content-language; bh=oZSwNDTQE6wHoAx64RntiWGx7Zw6F6VIIKSpa+cvjO0=; b=mjm595ixiYU7VCkkUMzNZckTFgvqQ34fOydYaMYAih1h0CCB+y7qZe2FPnEL+kfIzU ZslbsZ7YoFD72G2hwUBc5RGkiLQbe8Pw7APcZzjxE47CTrhF1HoN2dGPrZnuMCqEcfmh p45ehMUw3aNB5tAdBFQczsNpwpTKIBcaBu4BJ7oOKOBnItIxbLnJ+Ci1l/T86ATjPJIW 2SdD6YN/oeYOj5QzhspJ14RGZ1k3an7xptG7Tw+nc8nD5WrskPe4cxAF4w+DNXA66Q1v ah4eQu1NBBd9vkDtzvPNFHDIdA03Tv/Kb23emvDtehG7BvtLdfKFAIr3JiRA1BxLFrxV MXXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:to:cc:message-id:date:user-agent :mime-version:content-transfer-encoding:content-language; bh=oZSwNDTQE6wHoAx64RntiWGx7Zw6F6VIIKSpa+cvjO0=; b=OPn5plx15DaYjfFMghTuoJsv2qoF51wJuXiT115k2sv7Sj2d3qrFnwzw3p7uRyU513 tvefZo7m/XtQ/KCohgCwY048AtG/1NqjxbZVel8WyBe5rEyg99FLCNmzpCsTD/xT2qQi LE+R+a40ZeOmCwXnY2soCgT2n/dDZYT/XNdIsNdLml24MIDefRi359PT2ysr1xeIYM8O X06iaXt26mvvgneKDTa6K7QkFqiRIFLdr8sUHFgaGRWpXGA3NpUP6NMrbXL/qML4cVoP zif/N8LY5aer6zEV7lZT1wJ0wHKGcuUZyvUagSdDytAf9rnSDgKdMEzo++28ff3mCUw+ QEvw== X-Gm-Message-State: APjAAAWg48Jni/mGlJbJ/O5+Wy1UtMfQ6YHZUXcHf3sBaICko8G5JchZ heDHDsJuRwOBO+twNJ9kggT0SWZmyY4= X-Received: by 2002:a17:90a:376f:: with SMTP id u102mr92762286pjb.5.1564048184358; Thu, 25 Jul 2019 02:49:44 -0700 (PDT) Received: from ?IPv6:2402:f000:4:72:808::177e? ([2402:f000:4:72:808::177e]) by smtp.gmail.com with ESMTPSA id p13sm127488877pjb.30.2019.07.25.02.49.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 25 Jul 2019 02:49:43 -0700 (PDT) From: Jia-Ju Bai Subject: [BUG] fs: f2fs: Possible null-pointer dereferences in update_general_status() To: jaegeuk@kernel.org, yuchao0@huawei.com Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Message-ID: Date: Thu, 25 Jul 2019 17:49:44 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In update_general_status(), there are two if statements to check whether SM_I(sbi) is NULL: LINE 70:     if (SM_I(sbi) && SM_I(sbi)->fcc_info) LINE 78:     if (SM_I(sbi) && SM_I(sbi)->dcc_info) When SM_I(sbi) is NULL, it is used at some places, such as: LINE 88: reserved_segments(sbi)                   return SM_I(sbi)->reserved_segments; LINE 89: overprovision_segments(sbi)                   return SM_I(sbi)->ovp_segments; LINE 112: MAIN_SEGS(sbi)                     (SM_I(sbi)->main_segments) Thus, possible null-pointer dereferences may occur. These bugs are found by a static analysis tool STCheck written by us. I do not know how to correctly fix these bugs, so I only report them. Best wishes, Jia-Ju Bai